package com.beiye.drivertransport.SubActivity;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Camera;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.speech.tts.TextToSpeech;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.android.frame.view.linearlistview.LinearListView;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.Video.JZMediaIjk;
import com.beiye.drivertransport.Video.MyJZVideoPlayerStandard;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.adapter.CourseDetailRvSubjectApt;
import com.beiye.drivertransport.bean.CheckBean;
import com.beiye.drivertransport.bean.CourseDetailBean;
import com.beiye.drivertransport.bean.CourseDetailSubjectBean;
import com.beiye.drivertransport.bean.LoginUserBean;
import com.beiye.drivertransport.bean.SignBean;
import com.beiye.drivertransport.bean.SpecifiedLearningCourseBean;
import com.beiye.drivertransport.bean.SpecifiedPhotoBean;
import com.beiye.drivertransport.bean.UserTcPhoto;
import com.beiye.drivertransport.config.AppInterfaceConfig;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.safelearn.DailyTrainingExaminationItemActivity;
import com.beiye.drivertransport.safelearn.SpecifiedLearningHomeActivity;
import com.beiye.drivertransport.thirdparty.tbs.SuperFileView2;
import com.beiye.drivertransport.utils.FileParseUtil;
import com.beiye.drivertransport.utils.HelpUtil;
import com.beiye.drivertransport.utils.LogUtils;
import com.beiye.drivertransport.utils.MessageEvent;
import com.beiye.drivertransport.utils.MusicUtils;
import com.beiye.drivertransport.utils.TiShiDialog;
import com.beiye.drivertransport.utils.UserManger;
import com.beiye.drivertransport.utils.Utils;
import com.beiye.drivertransport.view.CircularProgressView;
import com.beiye.drivertransport.view.LiumRadioGroup;
import com.githang.statusbar.StatusBarCompat;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.picasso.Picasso;

import net.frakbot.jumpingbeans.JumpingBeans;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;


import butterknife.OnClick;
import cn.jzvd.JZDataSource;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;
import es.dmoral.toasty.Toasty;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

//行管发布
public class EnterpriseAdministratorCourseDetailsActivity extends TwoBaseAty implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener {


    WebView web;

    LinearLayout le_parement;

    ImageView img_Courseback;

    ImageView img_course2;

    RecyclerView lv_coursedetail;

    MyJZVideoPlayerStandard jcVideoPlayerStandard;

    TextView tv_courseName;

    ScrollView scroll_view;

    TextView tv_courseLength;

    TextView tv_course12;//中途保存退出

    LinearLayout totalle_course;//隐藏照片

    LinearLayout le_course1;//隐藏照片
    //    @Bind(R.id.tv_course3)
//    Chronometer tv_cumulativeLength;//累计时长

    TextView tv_cumulativeLength;//累计时长


    ImageView show_camera_iv;//显示照片第一张

    ImageView show_camera_iv1;//显示照片第二张

    ImageView show_camera_iv2;//显示照片第三张

    ImageView show_camera_iv3;//显示照片第四张

    ImageView show_camera_iv4;//显示照片第五张
    //    @Bind(R.id.id_area_sv)
//    SurfaceView surfaceSv;//预览照片

    TextView tv_sure;

    RelativeLayout re_course;//隐藏按钮

    RelativeLayout re_course2;//隐藏语音
    //    @Bind(R.id.re_course1)
//    RelativeLayout re_course1;//照片布局

    TextView img_course;

    TextView tv_course11;//请回答

    ImageView playOrPauseFab;//播放

    SeekBar musicSeekBar;//

    TextView tv_playorpause;//播放与暂停显示

    TextView progress_tv;//播放进度时间

    TextView total_tv;//播放总时间
    private MediaPlayer mediaPlayer;
    private MusicHandler musicHandler;


    SuperFileView2 mSuperFileView;
    private JumpingBeans jumpingBeans2;
    private PopupWindow mDownloadPopWindow;

    //请求访问外部存储
//    private static final int READ_EXTERNAL_STORAGE_REQUEST_CODE = 103;
    //请求写入外部存储
    //   private static final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 104;
    //   private File tempFile;
    //   private int type;
    //请求相机
    //   private static final int REQUEST_CAPTURE = 100;
    //请求相册
//    private static final int REQUEST_PICK = 101;
    //请求截图
//    private static final int REQUEST_CROP_PHOTO = 102;
//    private static final String TAG = EnterpriseAdministratorCourseDetailsActivity.class.getSimpleName();
//    private static final int MEDIA_TYPE_IMAGE = 1;
    private Timer mOffTime;
    private boolean isloob = true;
    //    private long mRecordTime;
    private TimerTask timerTask;
    private Handler mOffHandler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what > 0) {
                ////动态显示倒计时
                downtime.setText(msg.what + "");
            } else {
                ////倒计时结束自动关闭
                if (mPopWindow != null) {
                    downtime.setVisibility(View.GONE);
                    tv_photo.setText("请拍照，继续学习！");
                    tv_photo4.setVisibility(View.GONE);
                    tv_photo1.setText("你未在规定时间内操作");
                    tv_photo.setTextColor(Color.parseColor("#ff8092"));
                    tv_photo2.setVisibility(View.GONE);
                    img_photo.setImageResource(R.mipmap.sorry);
                    //   mPopWindow.dismiss();
                    //   timerTask.cancel();
                    Resave(); //自动保存方法
//                    if(!EnterpriseAdministratorCourseDetailsActivity.this.isFinishing())
//                    {
//                        timerTask.cancel();
//                        initDialog2();
//                        ShowSorryPopwindow();
//                    }

                }
                // off();////关闭后的操作
                mOffTime.cancel();
            }
            super.handleMessage(msg);
        }
    };


    private int formattimecnt;
    Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            int what = msg.what;
            if (what == 0) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn + utchSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {

                                        timerTask.cancel();
                                        //tv_pause.setVisibility(View.GONE);
                                        initDialog();

                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int firsttime2 = sp1.getInt("intfirsttime2" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String firsttimestr2 = getStringTime(firsttime2);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    LogUtils.e("第一次验证", firsttimestr2);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
//                                        else if (numTime==firsttime2) {
//                                            edit.putString("firsttime" + otcSn, firsttimestr2);
//                                            edit.commit();
//                                            timerTask.cancel();
//                                            initDialog();
//                                        }
                                        }
                                    } else if (numTime == firsttime2) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr2);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
//                                        else if (numTime==firsttime2) {
//                                            edit.putString("firsttime" + otcSn, firsttimestr2);
//                                            edit.commit();
//                                            timerTask.cancel();
//                                            initDialog();
//                                        }
                                        }

                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int num = sp1.getInt("num" + tcsn, 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + num);
//                                        String[] splitformat = stringTime.split(":");
//                                        String format1 = splitformat[0];
//                                        String format2 = splitformat[1];
//                                        String format3 = splitformat[2];
//                                        int iformat1 = Integer.valueOf(format1);//转int
//                                        int iformat2 = Integer.valueOf(format2);//转int
//                                        int iformat3 = Integer.valueOf(format3);//转int
//                                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                        if(formattime==courseLength*60) {
//                                            timerTask.cancel();
//                                        }
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            timerTask.cancel();
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }

                                                //有题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn1 = sp2.getInt("tcsn", 0);
                                                int utchSn1 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                                                if (imgurl1.equals("")) {

                                                    initDialog();
                                                    return;
                                                }

                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                photoList.add(userTcPhoto);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn1, tcsn1, atcSn, courseLength, photoList);
                                            } else {//无题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn1 = sp2.getInt("tcsn", 0);
                                                int utchSn1 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                                                if (imgurl1.equals("")) {

                                                    initDialog();
                                                    return;
                                                }

                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                photoList.add(userTcPhoto);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn1, tcsn1, atcSn, courseLength, photoList);

                                            }
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 2) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn1 = sp1.getInt("tcsn", 0);
                int utchSn1 = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn1 + utchSn1, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 1;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LogUtils.e("format", stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    int tcsn1 = sp1.getInt("tcsn", 0);
                                    int utchSn1 = sp1.getInt("utchSn", 0);
                                    edit.putString("format" + tcsn1 + utchSn1, stringTime);
                                    edit.commit();

                                    int courseLength = sp1.getInt("courseLength", 0);
                                    String courseLengthtime1 = getStringTime(courseLength * 60);
//                                    int num = sp1.getInt("num"+ otcSn, 0);
//                                    String[] splitformat = stringTime.split(":");
//                                    String format1 = splitformat[0];
//                                    String format2 = splitformat[1];
//                                    String format3 = splitformat[2];
//                                    int iformat1 = Integer.valueOf(format1);//转int
//                                    int iformat2 = Integer.valueOf(format2);//转int
//                                    int iformat3 = Integer.valueOf(format3);//转int
//                                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                    if(formattime==courseLength*60) {
//                                        timerTask.cancel();
//                                    }
                                    if (stringTime.equals(courseLengthtime1)) {
                                        tv_cumulativeLength.setText(courseLengthtime1);
                                        timerTask.cancel();
                                        if (rowscourseList.size() != 0) {
                                            for (int i = 0; i < rowscourseList.size(); i++) {
                                                if (rowscourseList.get(i).isSelect() == false) {
                                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                    builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                    builder1.setTitle("提示:");
                                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                            dialog.dismiss();
                                                            //设置你的操作事项
                                                        }
                                                    });

                                                    builder1.create().show();
                                                    return;
                                                } else {

                                                    if (rowscourseList.get(i).isLOOP() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });
                                                        builder1.create().show();

                                                        return;
                                                    }
                                                }
                                            }


                                            //有题无照片
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int utchSn2 = sp2.getInt("utchSn", 0);
                                            int atcSn = sp2.getInt("atcSn", 0);
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimestr);
                                            photoList.add(userTcPhoto);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(sn, utchSn1, tcsn1, atcSn, courseLength, photoList);
                                        } else {
                                            //无题情况无照片
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int utchSn2 = sp2.getInt("utchSn", 0);
                                            int atcSn = sp2.getInt("atcSn", 0);
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimestr);
                                            photoList.add(userTcPhoto);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(sn, utchSn1, tcsn1, atcSn, courseLength, photoList);

                                        }

                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {


                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(formattimecnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LogUtils.e("format", stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.commit();
                                    int courseLength = sp1.getInt("courseLength", 0);
                                    String courseLengthtime1 = getStringTime(courseLength * 60);
                                    if (stringTime.equals(courseLengthtime1)) {
                                        tv_cumulativeLength.setText(courseLengthtime1);
                                        timerTask.cancel();
                                        if (rowscourseList.size() != 0) {
                                            for (int i = 0; i < rowscourseList.size(); i++) {
                                                if (rowscourseList.get(i).isSelect() == false) {
                                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                    builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                    builder1.setTitle("提示:");
                                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                            dialog.dismiss();
                                                            //设置你的操作事项
                                                        }
                                                    });

                                                    builder1.create().show();
                                                    return;
                                                } else {

                                                    if (rowscourseList.get(i).isLOOP() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });
                                                        builder1.create().show();

                                                        return;
                                                    }
                                                }
                                            }
                                            //有题无照片
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int utchSn2 = sp2.getInt("utchSn", 0);
                                            int atcSn = sp2.getInt("atcSn", 0);
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimestr);
                                            photoList.add(userTcPhoto);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                        } else {
                                            //无题情况无照片
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int utchSn2 = sp2.getInt("utchSn", 0);
                                            int atcSn = sp2.getInt("atcSn", 0);
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimestr);
                                            photoList.add(userTcPhoto);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);

                                        }
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }

            }
//            else if (what == 1) {
//                WebSettings settings = web.getSettings();
//                // 允许使用脚本语言
//                settings.setJavaScriptEnabled(true);
//                // 支持缩放
//                settings.setSupportZoom(true);
//                //  mWebView.addJavascriptInterface(new JavaScriptinterface(BannerItemAty.this), "android");
//                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
//                    settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
//                }//Android 5.0中使用webView 加载网页不显示图片问题
//                // 在当前应用加载网页(直接加载网页不经过浏览器）
//                web.setWebViewClient(new WebViewClient() {
//                    @Override // 开始加载网页时触发
//                    public void onPageStarted(WebView view, String url, Bitmap favicon) {
//                        super.onPageStarted(view, url, favicon);
//
//                    }
//
//                    @Override // 网页加载完成之后触发
//                    public void onPageFinished(WebView view, String url) {
//
//                        super.onPageFinished(view, url);
//
//                    }
//                });
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int tcsn = sp.getInt("tcsn", 0);
//                web.loadUrl(AppInterfaceConfig.BASE_URL + "app/course/content?" + "sn=" + tcsn);
//                // 显示进度
//                web.setWebChromeClient(new WebChromeClient() {
//                    @Override // 加载网页进度改变时触发
//                    public void onProgressChanged(WebView view, int newProgress) {
//                        super.onProgressChanged(view, newProgress);
//                    }
//                });
//            }
            else if (what == 3) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn + utchSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {

                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    //  int firsttime2 = sp1.getInt("intfirsttime2" + otcSn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    //     String firsttimestr2= getStringTime(firsttime2);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }
                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }
                                    } else {
                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int num = sp1.getInt("num" + tcsn, 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + num);
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }


                                                //有题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }

                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            } else {//无题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }

                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            }
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);

                }
            } else if (what == 4) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn + utchSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    //   int firsttime1 = sp1.getInt("intfirsttime2" + otcSn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    //  String firsttimestr2 = getStringTime(firsttime1);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }
                                    } else if (numTime == numsecondpart) {

                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }

                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int num = sp1.getInt("num" + tcsn, 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + num);
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }


                                                //有题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            } else {//无题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            }
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }

            } else if (what == 5) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn + utchSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numthirdpartstr = getStringTime(numthirdpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numthirdpartstr);
                                    LogUtils.e("第四次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }

                                    } else if (numTime == numsecondpart) {

                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }

                                    } else if (numTime == numthirdpart) {

                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }

                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog5();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int num = sp1.getInt("num" + tcsn, 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + num);
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }


                                                //有题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                String imgurl4 = sp2.getString("imgurl3" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                if (imgurl4.equals("")) {
                                                    initDialog5();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numthirdpartstrsub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numthirdpartstrsub);
                                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                                userTcPhoto3.setUrl(imgurl4);
                                                userTcPhoto3.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                photoList.add(userTcPhoto3);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            } else {//无题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                String imgurl4 = sp2.getString("imgurl3" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                if (imgurl4.equals("")) {
                                                    initDialog5();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numthirdpartstrsub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numthirdpartstrsub);
                                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                                userTcPhoto3.setUrl(imgurl4);
                                                userTcPhoto3.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                photoList.add(userTcPhoto3);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            }
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 6) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                int sn = sp1.getInt("sn", 0);
                String format = sp1.getString("format" + tcsn + utchSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int minPer = sp1.getInt("minPer", 0);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int utchSn = sp1.getInt("utchSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                                    int numfourpart = sp1.getInt("numfourpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numthirdpartstr = getStringTime(numthirdpart);
                                    String numfourpartstr = getStringTime(numfourpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numthirdpartstr);
                                    LogUtils.e("第四次", numfourpartstr);
                                    LogUtils.e("第五次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + utchSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                    edit.putString("numfourpartstr" + tcsn, numfourpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
                                    if (numTime == firsttime) {

                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }

                                    } else if (numTime == numsecondpart) {
                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }
                                    } else if (numTime == numthirdpart) {

                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }

                                    } else if (numTime == numfourpart) {
                                        if (show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numfourpartstr" + tcsn, numfourpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog5();
                                        }
                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog6();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int num = sp1.getInt("num" + tcsn, 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + num);
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }


                                                //有题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                                String numfourpartstr1 = sp2.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                String imgurl4 = sp2.getString("imgurl3" + tcsn2 + utchSn2, "");
                                                String imgurl5 = sp2.getString("imgurl4" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                if (imgurl4.equals("")) {
                                                    initDialog5();
                                                    return;
                                                }
                                                if (imgurl5.equals("")) {
                                                    initDialog6();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numthirdpartstrsub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numfourpartstrsub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numthirdpartstrsub);
                                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                                userTcPhoto3.setUrl(imgurl4);
                                                userTcPhoto3.setSnapTime(numfourpartstrsub);
                                                UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                                                userTcPhoto4.setUrl(imgurl5);
                                                userTcPhoto4.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                photoList.add(userTcPhoto3);
                                                photoList.add(userTcPhoto4);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            } else {//无题有照片自动提交
                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
                                                String userId1 = userInfo1.getData().getUserId();
                                                SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                                        Context.MODE_PRIVATE);
                                                int tcsn2 = sp2.getInt("tcsn", 0);
                                                int utchSn2 = sp2.getInt("utchSn", 0);
                                                int atcSn = sp2.getInt("atcSn", 0);
                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                                String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                                String numfourpartstr1 = sp2.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                                                String imgurl1 = sp2.getString("imgurl" + tcsn2 + utchSn2, "");
                                                String imgurl2 = sp2.getString("imgurl1" + tcsn2 + utchSn2, "");
                                                String imgurl3 = sp2.getString("imgurl2" + tcsn2 + utchSn2, "");
                                                String imgurl4 = sp2.getString("imgurl3" + tcsn2 + utchSn2, "");
                                                String imgurl5 = sp2.getString("imgurl4" + tcsn2 + utchSn2, "");
                                                if (imgurl1.equals("")) {
                                                    initDialog();
                                                    return;
                                                }
                                                if (imgurl2.equals("")) {
                                                    initDialog3();
                                                    return;
                                                }
                                                if (imgurl3.equals("")) {
                                                    initDialog4();
                                                    return;
                                                }
                                                if (imgurl4.equals("")) {
                                                    initDialog5();
                                                    return;
                                                }
                                                if (imgurl5.equals("")) {
                                                    initDialog6();
                                                    return;
                                                }
                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numthirdpartstrsub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numfourpartstrsub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                                String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                                userTcPhoto.setUrl(imgurl1);
                                                userTcPhoto.setSnapTime(firsttimesub);
                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                                userTcPhoto1.setUrl(imgurl2);
                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                                userTcPhoto2.setUrl(imgurl3);
                                                userTcPhoto2.setSnapTime(numthirdpartstrsub);
                                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                                userTcPhoto3.setUrl(imgurl4);
                                                userTcPhoto3.setSnapTime(numfourpartstrsub);
                                                UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                                                userTcPhoto4.setUrl(imgurl5);
                                                userTcPhoto4.setSnapTime(numFifthpartstrsub);
                                                photoList.add(userTcPhoto);
                                                photoList.add(userTcPhoto1);
                                                photoList.add(userTcPhoto2);
                                                photoList.add(userTcPhoto3);
                                                photoList.add(userTcPhoto4);
                                                Gson gson = new Gson();
                                                String strphotoList = gson.toJson(photoList);
                                                LogUtils.e("strphotoList", strphotoList);
                                                initsuredata(sn, utchSn2, tcsn2, atcSn, courseLength, photoList);
                                            }
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            }
        }
    };
    private CourseDetailRvSubjectApt courseDetailSubjectApt;
    private Camera mCamera;
    private SurfaceHolder mHolder;
    private PopupWindow mPopWindow;
    private long rangeTime;
    private FileInputStream fStream;

    private ArrayList<CourseDetailSubjectBean.RowsBean> rowscourseList = new ArrayList<>();

    private Timer timer1;


    private int subformatTurnSecond;
    private SensorManager sensorManager;
    private Jzvd.JZAutoFullscreenListener sensorEventListener;

    private TextView downtime;
    private PopupWindow mSorryPopWindow;
    //  private CustomProgressDialog mdialog;
    private ProgressDialog mProgressDialog;
    private PopupWindow mStopPopWindow;
    private Handler mainHandler;
    private TextToSpeech textToSpeech;
    private ArrayList<String> permissionList;
    private PopupWindow mPopWindow2;
    // private boolean ishave=false;
    private TextView tv_photo2;
    private TextView tv_photo4;
    private TextView tv_photo1;
    private TextView tv_photo;
    private ImageView img_photo;
    //   private Animation animation;


    @Override
    public int getLayoutId() {
        return R.layout.activity_enterprise_administrator_course_details;

    }


    private String getStringTime(int cnt) {
        int hour = cnt / 3600;
        int min = cnt % 3600 / 60;
        int second = cnt % 60;
        return String.format(Locale.CHINA, "%02d:%02d:%02d", hour, min, second);
    }

    private String getNumTime(int cnt) {
        int hour = cnt / 3600;
        int min = cnt % 3600 / 60;
        int second = cnt % 60;
        if (hour == 0) {
            return String.format(Locale.CHINA, "%02d分%02d秒", min, second);
        } else {

            return String.format(Locale.CHINA, "%02d小时%02d分%02d秒", hour, min, second);
        }
    }

    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.img_playorpause) {
            toggle();
        } else if (id == R.id.img_Courseback) {
            LoginUserBean userInfo2 = UserManger.getUserInfo();
            String userId3 = userInfo2.getData().getUserId();
            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId3,
                    Context.MODE_PRIVATE);
            int tcsn2 = sp1.getInt("tcsn", 0);
            int utchSn2 = sp1.getInt("utchSn", 0);
            int tphotoMark = sp1.getInt("tphotoMark", 0);
            int atcSn = sp1.getInt("atcSn", 0);
            int sn = sp1.getInt("sn", 0);
            int courseLength2 = sp1.getInt("courseLength", 0);
            String formats2 = sp1.getString("format" + tcsn2 + utchSn2, "");
            String[] splitformat2 = formats2.split(":");
            String formatstr7 = splitformat2[0];
            String formatstr8 = splitformat2[1];
            String formatstr9 = splitformat2[2];
            int iformat7 = Integer.valueOf(formatstr7);//转int
            int iformat8 = Integer.valueOf(formatstr8);//转int
            int iformat9 = Integer.valueOf(formatstr9);//转int
            int formattime2 = iformat7 * 3600 + iformat8 * 60 + iformat9 * 1;
            if (formattime2 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dialog.dismiss();
                    }
                });


            } else {
                if (formattime2 >= courseLength2 * 60) {
                    if (rowscourseList.size() != 0) {
                        for (int i = 0; i < rowscourseList.size(); i++) {
                            if (rowscourseList.get(i).isSelect() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });

                                builder1.create().show();
                                return;
                            } else {

                                if (rowscourseList.get(i).isLOOP() == false) {
                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                    builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                    builder1.setTitle("提示:");
                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.dismiss();
                                            //设置你的操作事项
                                        }
                                    });
                                    builder1.create().show();

                                    return;
                                }
                            }
                        }
                    }
                    //有题目接口
//                        int photoMark2 = sp1.getInt("photoMark", 0);
//                        int tcsn2 = sp1.getInt("tcsn", 0);
//                        int sn2 = sp1.getInt("sn", 0);
//                        String orgId2 = sp1.getString("orgId", "");
                    if (tphotoMark == 1) {//照片提交

                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }

                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        // String durationsub = duration.substring(3,8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
//
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        //  showLoadingDialog("提交中");
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);

                    } else if (tphotoMark == 0)//无照片提交
                    {
                        //有题目调提交接口
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttime);
                        photoList.add(userTcPhoto);
//
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);

                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
//
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);
                    } else if (tphotoMark == 2) {
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn2 + utchSn2, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }

                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);
                    } else if (tphotoMark == 3) {
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn2 + utchSn2, "");

                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }

                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);
                    } else if (tphotoMark == 4) {
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn2 + utchSn2, "");
                        String imgurl3 = sp1.getString("imgurl3" + tcsn2 + utchSn2, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            initDialog5();
                            return;
                        }

                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);
                    } else if (tphotoMark == 5) {
                        String imgurl = sp1.getString("imgurl" + tcsn2 + utchSn2, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn2 + utchSn2, "");
                        String imgurl3 = sp1.getString("imgurl3" + tcsn2 + utchSn2, "");
                        String imgurl4 = sp1.getString("imgurl4" + tcsn2 + utchSn2, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            initDialog5();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            initDialog6();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                        String numfourpartstr = sp1.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl4);
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId3, utchSn2, tcsn2, atcSn, courseLength2, 1, photoList, this, 3);
                    }
                }
//                        else{//无题目接口
//                            int photoMark2 = sp1.getInt("photoMark", 0);
//                            int tcsn2 = sp1.getInt("tcsn", 0);
//                            int sn2 = sp1.getInt("sn", 0);
//                            String orgId2 = sp1.getString("orgId", "");
//                            if (photoMark2 == 1) {//照片提交
//
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                //                       String durationsub = duration.substring(3,8);//截取字符串00:00:00变成00:00
//                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttimesub);
//                                photoList.add(userTcPhoto);
////
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//                                //  showLoadingDialog("提交中");
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
////
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            } else if (photoMark2 == 0)//无照片提交
//                            {//没有题目调提交接口
//
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttime);
//                                photoList.add(userTcPhoto);
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
////
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            }else  if(photoMark2 == 2)
//                            {
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String imgurl1 = sp1.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                String numFifthpartstr = sp1.getString("numFifthpartstr" + otcSn2, "");//第二次抓拍时间
//                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttimesub);
//                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                userTcPhoto1.setUrl(imgurl1);
//                                userTcPhoto1.setSnapTime(numFifthpartstr1);
//                                photoList.add(userTcPhoto);
//                                photoList.add(userTcPhoto1);
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
////
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            }else if(photoMark2==3)
//                            {
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String imgurl1 = sp1.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                String imgurl2 = sp1.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                String numsecondpartstr = sp1.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                String numFifthpartstr = sp1.getString("numFifthpartstr" + otcSn2, "");//第三次抓拍时间
//                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttimesub);
//                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                userTcPhoto1.setUrl(imgurl1);
//                                userTcPhoto1.setSnapTime(numsecondpartstr1);
//                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                userTcPhoto2.setUrl(imgurl2);
//                                userTcPhoto2.setSnapTime(numFifthpartstr1);
//                                photoList.add(userTcPhoto);
//                                photoList.add(userTcPhoto1);
//                                photoList.add(userTcPhoto2);
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
////
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            }else if(photoMark2 == 4)
//                            {
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String imgurl1 = sp1.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                String imgurl2 = sp1.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                String imgurl3 = sp1.getString("imgurl3" + otcSn2 + learnsn2, "");
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                String numsecondpartstr = sp1.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                String numthirdpartstr = sp1.getString("numthirdpartstr" + otcSn2, "");//第三次抓拍时间
//                                String numFifthpartstr = sp1.getString("numFifthpartstr" + otcSn2, "");//第四次抓拍时间
//                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttimesub);
//                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                userTcPhoto1.setUrl(imgurl1);
//                                userTcPhoto1.setSnapTime(numsecondpartstr1);
//                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                userTcPhoto2.setUrl(imgurl2);
//                                userTcPhoto2.setSnapTime(numthirdpartstr1);
//                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
//                                userTcPhoto3.setUrl(imgurl3);
//                                userTcPhoto3.setSnapTime(numFifthpartstr1);
//                                photoList.add(userTcPhoto);
//                                photoList.add(userTcPhoto1);
//                                photoList.add(userTcPhoto2);
//                                photoList.add(userTcPhoto3);
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            }else if(photoMark2 ==5)
//                            {
//                                String imgurl = sp1.getString("imgurl" + otcSn2 + learnsn2, "");
//                                String imgurl1 = sp1.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                String imgurl2 = sp1.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                String imgurl3 = sp1.getString("imgurl3" + otcSn2 + learnsn2, "");
//                                String imgurl4 = sp1.getString("imgurl4" + otcSn2 + learnsn2, "");
//                                String firsttime = sp1.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                String numsecondpartstr = sp1.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                String numthirdpartstr = sp1.getString("numthirdpartstr" + otcSn2, "");//第三次抓拍时间
//                                String numfourpartstr = sp1.getString("numfourpartstr" + otcSn2, "");//第四次抓拍时间
//                                String numFifthpartstr = sp1.getString("numFifthpartstr" + otcSn2, "");//第五次抓拍时间
//                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                userTcPhoto.setUrl(imgurl);
//                                userTcPhoto.setSnapTime(firsttimesub);
//                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                userTcPhoto1.setUrl(imgurl1);
//                                userTcPhoto1.setSnapTime(numsecondpartstr1);
//                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                userTcPhoto2.setUrl(imgurl2);
//                                userTcPhoto2.setSnapTime(numthirdpartstr1);
//                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
//                                userTcPhoto3.setUrl(imgurl3);
//                                userTcPhoto3.setSnapTime(numfourpartstr1);
//                                UserTcPhoto userTcPhoto4 = new UserTcPhoto();
//                                userTcPhoto4.setUrl(imgurl4);
//                                userTcPhoto4.setSnapTime(numFifthpartstr1);
//                                photoList.add(userTcPhoto);
//                                photoList.add(userTcPhoto1);
//                                photoList.add(userTcPhoto2);
//                                photoList.add(userTcPhoto3);
//                                photoList.add(userTcPhoto4);
//                                Gson gson = new Gson();
//                                String strphotoList = gson.toJson(photoList);
//                                LogUtils.e("strphotoList", strphotoList);
//                                mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                                mProgressDialog.setMessage("提交中...");
//                                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                                mProgressDialog.setCancelable(false);
//                                mProgressDialog.show();
//                                new Login().getSureCosrseAndLearn(sn2, userId3, orgId2, tcsn2, otcSn2, learnsn2, courseLength2, 1, photoList, this, 3);
//                            }
//                        }
                else if (formattime2 < courseLength2 * 60) {//滿一分鐘保存
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    int readLength = (formattime2 % 60 == 0) ? formattime2 / 60 : (formattime2 / 60);//累计学习时间
                    if (tphotoMark == 1) {
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");

                        //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    } else if (tphotoMark == 0) {
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");
                        //   int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //      String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    } else if (tphotoMark == 2) {
                        //   int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String imgurl2 = sp.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numFifthpartstr);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numFifthpartstr1);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    } else if (tphotoMark == 3) {
                        //     int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String imgurl2 = sp.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String imgurl3 = sp.getString("imgurl2" + tcsn2 + utchSn2, "");
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numFifthpartstr);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numFifthpartstr1);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    } else if (tphotoMark == 4) {
                        //     int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String imgurl2 = sp.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String imgurl3 = sp.getString("imgurl2" + tcsn2 + utchSn2, "");
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                        String imgurl4 = sp.getString("imgurl3" + tcsn2 + utchSn2, "");
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numthirdpartstr);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numthirdpartstr1);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        if (imgurl4.equals("")) {
                            userTcPhoto3.setSnapTime(numFifthpartstr);
                            userTcPhoto3.setUrl(imgurl4);

                        } else {
                            String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto3.setSnapTime(numFifthpartstr1);
                            userTcPhoto3.setUrl(imgurl4);
                        }
                        photoList.add(userTcPhoto3);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    } else if (tphotoMark == 5) {
                        //     int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        LogUtils.e("readLength", readLength + "");
                        String imgurl1 = sp.getString("imgurl" + tcsn2 + utchSn2, "");
                        String firsttime = sp.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                        String imgurl2 = sp.getString("imgurl1" + tcsn2 + utchSn2, "");
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                        String imgurl3 = sp.getString("imgurl2" + tcsn2 + utchSn2, "");
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                        String imgurl4 = sp.getString("imgurl3" + tcsn2 + utchSn2, "");
                        String numfourpartstr = sp.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                        String imgurl5 = sp.getString("imgurl4" + tcsn2 + utchSn2, "");
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numthirdpartstr);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numthirdpartstr1);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        if (imgurl4.equals("")) {
                            userTcPhoto3.setSnapTime(numfourpartstr);
                            userTcPhoto3.setUrl(imgurl4);

                        } else {
                            String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto3.setSnapTime(numfourpartstr1);
                            userTcPhoto3.setUrl(imgurl4);
                        }
                        photoList.add(userTcPhoto3);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        if (imgurl5.equals("")) {
                            userTcPhoto4.setSnapTime(numFifthpartstr);
                            userTcPhoto4.setUrl(imgurl5);

                        } else {
                            String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto4.setSnapTime(numFifthpartstr1);
                            userTcPhoto4.setUrl(imgurl5);
                        }
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(sn, utchSn2, tcsn2, atcSn, readLength, photoList);
                    }
//                            }
//                        });
                }
            }
        } else if (id == R.id.tv_course12) {//中途保存退出

            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId1 = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                    Context.MODE_PRIVATE);
            int tcsn = sp.getInt("tcsn", 0);
            int utchSn = sp.getInt("utchSn", 0);
            int tphotoMark1 = sp.getInt("tphotoMark", 0);
            int sn1 = sp.getInt("sn", 0);
            int atcSn1 = sp.getInt("atcSn", 0);
            int courseLength1 = sp.getInt("courseLength", 0);
            String formats1 = sp.getString("format" + tcsn + utchSn, "");
            String[] splitformat1 = formats1.split(":");
            String formatstr1 = splitformat1[0];
            String formatstr2 = splitformat1[1];
            String formatstr3 = splitformat1[2];
            int iformat4 = Integer.valueOf(formatstr1);//转int
            int iformat5 = Integer.valueOf(formatstr2);//转int
            int iformat6 = Integer.valueOf(formatstr3);//转int
            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
            if (formattime1 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();

                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dialog.dismiss();
                    }
                });

            } else {
                if (formattime1 >= courseLength1 * 60) {
                    if (rowscourseList.size() != 0) {
                        for (int i = 0; i < rowscourseList.size(); i++) {
                            if (rowscourseList.get(i).isSelect() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });

                                builder1.create().show();
                                return;
                            } else {

                                if (rowscourseList.get(i).isLOOP() == false) {
                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                    builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                    builder1.setTitle("提示:");
                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.dismiss();
                                            //设置你的操作事项
                                        }
                                    });
                                    builder1.create().show();

                                    return;
                                }
                            }
                        }
                    }
                    //有题目接口
//                        int photoMark1 = sp.getInt("photoMark", 0);
//                        int tcsn1 = sp.getInt("tcsn", 0);
//                        int sn1 = sp.getInt("sn", 0);
//                        String orgId1 = sp.getString("orgId", "");
                    if (tphotoMark1 == 1) {//有照片提交

                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                       String durationsub = duration.substring(3,8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();

                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    } else if (tphotoMark1 == 0)//无照片提交
                    {
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttime);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    } else if (tphotoMark1 == 2) {
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn + utchSn, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    } else if (tphotoMark1 == 3) {
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String imgurl1 = sp.getString("imgurl1" + tcsn + utchSn, "");
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String imgurl2 = sp.getString("imgurl2" + tcsn + utchSn, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }

                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    } else if (tphotoMark1 == 4) {
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn + utchSn, "");
                        String imgurl2 = sp.getString("imgurl2" + tcsn + utchSn, "");
                        String imgurl3 = sp.getString("imgurl3" + tcsn + utchSn, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            initDialog5();
                            return;
                        }

                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    } else if (tphotoMark1 == 5) {
                        String imgurl = sp.getString("imgurl" + tcsn + utchSn, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn + utchSn, "");
                        String imgurl2 = sp.getString("imgurl2" + tcsn + utchSn, "");
                        String imgurl3 = sp.getString("imgurl3" + tcsn + utchSn, "");
                        String imgurl4 = sp.getString("imgurl4" + tcsn + utchSn, "");
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            initDialog5();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            initDialog6();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                        String numfourpartstr = sp.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl4);
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn1, userId1, utchSn, tcsn, atcSn1, courseLength1, 1, photoList, this, 3);
                    }
                }
//                       else{//没有题目调提交接口
//                           int photoMark1 = sp.getInt("photoMark", 0);
//                           int tcsn1 = sp.getInt("tcsn", 0);
//                           int sn1 = sp.getInt("sn", 0);
//                           String orgId1 = sp.getString("orgId", "");
//                           if (photoMark1 == 1) {//有照片提交
//
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                               //                       String durationsub = duration.substring(3,8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttimesub);
//                               photoList.add(userTcPhoto);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           } else if (photoMark1 == 0)//无照片提交
//                           {
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttime);
//                               photoList.add(userTcPhoto);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           }else if(photoMark1 == 2)
//                           {
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String imgurl1 = sp.getString("imgurl1" + otcSn1 + learnsn1, "");
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               String numFifthpartstr = sp.getString("numFifthpartstr" + otcSn1, "");//第二次抓拍时间
//                               String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttimesub);
//                               UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                               userTcPhoto1.setUrl(imgurl1);
//                               userTcPhoto1.setSnapTime(numFifthpartstr1);
//                               photoList.add(userTcPhoto);
//                               photoList.add(userTcPhoto1);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           }else if(photoMark1 == 3)
//                           {
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String imgurl1 = sp.getString("imgurl1" + otcSn1 + learnsn1, "");
//                               String imgurl2 = sp.getString("imgurl2" + otcSn1 + learnsn1, "");
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               String numsecondpartstr = sp.getString("numsecondpartstr" + otcSn1, "");//第二次抓拍时间
//                               String numFifthpartstr = sp.getString("numFifthpartstr" + otcSn1, "");//第三次抓拍时间
//                               String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttimesub);
//                               UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                               userTcPhoto1.setUrl(imgurl1);
//                               userTcPhoto1.setSnapTime(numsecondpartstr1);
//                               UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                               userTcPhoto2.setUrl(imgurl2);
//                               userTcPhoto2.setSnapTime(numFifthpartstr1);
//                               photoList.add(userTcPhoto);
//                               photoList.add(userTcPhoto1);
//                               photoList.add(userTcPhoto2);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           }else if(photoMark1 == 4)
//                           {
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String imgurl1 = sp.getString("imgurl1" + otcSn1 + learnsn1, "");
//                               String imgurl2 = sp.getString("imgurl2" + otcSn1 + learnsn1, "");
//                               String imgurl3 = sp.getString("imgurl3" + otcSn1 + learnsn1, "");
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               String numsecondpartstr = sp.getString("numsecondpartstr" + otcSn1, "");//第二次抓拍时间
//                               String numthirdpartstr = sp.getString("numthirdpartstr" + otcSn1, "");//第三次抓拍时间
//                               String numFifthpartstr = sp.getString("numFifthpartstr" + otcSn1, "");//第四次抓拍时间
//                               String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttimesub);
//                               UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                               userTcPhoto1.setUrl(imgurl1);
//                               userTcPhoto1.setSnapTime(numsecondpartstr1);
//                               UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                               userTcPhoto2.setUrl(imgurl2);
//                               userTcPhoto2.setSnapTime(numthirdpartstr1);
//                               UserTcPhoto userTcPhoto3 = new UserTcPhoto();
//                               userTcPhoto3.setUrl(imgurl3);
//                               userTcPhoto3.setSnapTime(numFifthpartstr1);
//                               photoList.add(userTcPhoto);
//                               photoList.add(userTcPhoto1);
//                               photoList.add(userTcPhoto2);
//                               photoList.add(userTcPhoto3);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           }else if(photoMark1 ==5)
//                           {
//                               String imgurl = sp.getString("imgurl" + otcSn1 + learnsn1, "");
//                               String imgurl1 = sp.getString("imgurl1" + otcSn1 + learnsn1, "");
//                               String imgurl2 = sp.getString("imgurl2" + otcSn1 + learnsn1, "");
//                               String imgurl3 = sp.getString("imgurl3" + otcSn1 + learnsn1, "");
//                               String imgurl4 = sp.getString("imgurl4" + otcSn1 + learnsn1, "");
//                               String firsttime = sp.getString("firsttime" + otcSn1, "");//第一次抓拍时间
//                               String numsecondpartstr = sp.getString("numsecondpartstr" + otcSn1, "");//第二次抓拍时间
//                               String numthirdpartstr = sp.getString("numthirdpartstr" + otcSn1, "");//第三次抓拍时间
//                               String numfourpartstr = sp.getString("numfourpartstr" + otcSn1, "");//第四次抓拍时间
//                               String numFifthpartstr = sp.getString("numFifthpartstr" + otcSn1, "");//第五次抓拍时间
//                               String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
//                               List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                               UserTcPhoto userTcPhoto = new UserTcPhoto();
//                               userTcPhoto.setUrl(imgurl);
//                               userTcPhoto.setSnapTime(firsttimesub);
//                               UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                               userTcPhoto1.setUrl(imgurl1);
//                               userTcPhoto1.setSnapTime(numsecondpartstr1);
//                               UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                               userTcPhoto2.setUrl(imgurl2);
//                               userTcPhoto2.setSnapTime(numthirdpartstr1);
//                               UserTcPhoto userTcPhoto3 = new UserTcPhoto();
//                               userTcPhoto3.setUrl(imgurl3);
//                               userTcPhoto3.setSnapTime(numfourpartstr1);
//                               UserTcPhoto userTcPhoto4 = new UserTcPhoto();
//                               userTcPhoto4.setUrl(imgurl4);
//                               userTcPhoto4.setSnapTime(numFifthpartstr1);
//                               photoList.add(userTcPhoto);
//                               photoList.add(userTcPhoto1);
//                               photoList.add(userTcPhoto2);
//                               photoList.add(userTcPhoto3);
//                               photoList.add(userTcPhoto4);
//                               Gson gson = new Gson();
//                               String strphotoList = gson.toJson(photoList);
//                               LogUtils.e("strphotoList", strphotoList);
//                               mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                               mProgressDialog.setMessage("提交中...");
//                               mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                               mProgressDialog.setCancelable(false);
//                               mProgressDialog.show();
//                               new Login().getSureCosrseAndLearn(sn1, userId1, orgId1, tcsn1, otcSn1, learnsn1, courseLength1, 1, photoList, this, 3);
//                           }
//                       }
                else if (formattime1 < courseLength1 * 60) {//滿一分鐘保存

                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                    tv_message.setText("您的学习进度已保存，下次进入将继续本课程的学习。");
                    TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                    btn_sure.setText("确认退出");
                    btn_cancel.setText("继续学习");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view1);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            String formats1 = sp.getString("format" + tcsn + utchSn, "");
                            String[] splitformat1 = formats1.split(":");
                            String formatstr1 = splitformat1[0];
                            String formatstr2 = splitformat1[1];
                            String formatstr3 = splitformat1[2];
                            int iformat4 = Integer.valueOf(formatstr1);//转int
                            int iformat5 = Integer.valueOf(formatstr2);//转int
                            int iformat6 = Integer.valueOf(formatstr3);//转int
                            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;

//                                int tcsn1 = sp.getInt("tcsn", 0);
//                                int sn1 = sp.getInt("sn", 0);
//                                String orgId1 = sp.getString("orgId", "");
//                                int photoMark = sp.getInt("photoMark", 0);
                            // int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1: (formattime1 / 60);//累计学习时间
                            int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            if (tphotoMark1 == 1) {

                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            } else if (tphotoMark1 == 0) {
                                //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                //      String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttime);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            } else if (tphotoMark1 == 2) {
                                //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                                String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numFifthpartstr);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numFifthpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            } else if (tphotoMark1 == 3) {
                                //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                                String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                                String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numFifthpartstr);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numFifthpartstr1);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);

                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            } else if (tphotoMark1 == 4) {
                                //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                                String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                                String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                                String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                                String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numthirdpartstr);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numthirdpartstr1);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);
                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                if (imgurl4.equals("")) {
                                    userTcPhoto3.setSnapTime(numFifthpartstr);
                                    userTcPhoto3.setUrl(imgurl4);

                                } else {
                                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto3.setSnapTime(numFifthpartstr1);
                                    userTcPhoto3.setUrl(imgurl4);
                                }
                                photoList.add(userTcPhoto3);

                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            } else if (tphotoMark1 == 5) {
                                //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                                LogUtils.e("readLength", readLength + "");
                                String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                                String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                                String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                                String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                                String numfourpartstr = sp.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                                String imgurl5 = sp.getString("imgurl4" + tcsn + utchSn, "");
                                String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numthirdpartstr);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numthirdpartstr1);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);
                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                if (imgurl4.equals("")) {
                                    userTcPhoto3.setSnapTime(numfourpartstr);
                                    userTcPhoto3.setUrl(imgurl4);

                                } else {
                                    String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto3.setSnapTime(numfourpartstr1);
                                    userTcPhoto3.setUrl(imgurl4);
                                }
                                photoList.add(userTcPhoto3);
                                UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                                if (imgurl5.equals("")) {
                                    userTcPhoto4.setSnapTime(numFifthpartstr);
                                    userTcPhoto4.setUrl(imgurl5);

                                } else {
                                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto4.setSnapTime(numFifthpartstr1);
                                    userTcPhoto4.setUrl(imgurl5);
                                }
                                photoList.add(userTcPhoto4);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(sn1, utchSn, tcsn, atcSn1, readLength, photoList);
                            }
                            //设置你的操作事项
                        }
                    });

                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {


//                                LoginUserBean userInfo = UserManger.getUserInfo();
//                                String userId = userInfo.getData().getUserId();
//                                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity"+userId,
//                                        Context.MODE_PRIVATE);
//                                int photoMark = sp.getInt("photoMark", 0);
//                                if(photoMark==1)
//                                {
//                                    Thread thread = new Thread(new Runnable() {
//                                        @Override
//                                        public void run() {
//                                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                            mHandler.sendEmptyMessage(0);
//                                        }
//                                    });
//                                    thread.start();
//                                }else if(photoMark==0){
//                                    Thread thread = new Thread(new Runnable() {
//                                        @Override
//                                        public void run() {
//                                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                            mHandler.sendEmptyMessage(2);
//                                        }
//                                    });
//                                    thread.start();
//                                }
                            //      tv_pause.setText("继续学习");
//                            LoginUserBean userInfo = UserManger.getUserInfo();
//                            String userId = userInfo.getData().getUserId();
//                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                    Context.MODE_PRIVATE);
//                            int photoMark = sp.getInt("photoMark", 0);
//                            if (photoMark == 1) {
//                                Thread thread = new Thread(new Runnable() {
//                                    @Override
//                                    public void run() {
//                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                        mHandler.sendEmptyMessage(0);
//                                    }
//                                });
//                                thread.start();
//                            } else if (photoMark == 0) {
//                                Thread thread = new Thread(new Runnable() {
//                                    @Override
//                                    public void run() {
//                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                        mHandler.sendEmptyMessage(2);
//                                    }
//                                });
//                                thread.start();
//                            }
                            dialog.dismiss();
                        }
                    });
                }

            }

//            case R.id.img_course2://暂停学习功能
//                if (tv_pause.getText().toString().equals("暂停学习")) {
//                    timerTask.cancel();
//                    initStopDialog();
//                    tv_pause.setText("继续学习");
//                } else if (tv_pause.getText().toString().equals("继续学习")) {
//                    tv_pause.setText("暂停学习");
//                    LoginUserBean userInfo1 = UserManger.getUserInfo();
//                    String userId2 = userInfo1.getData().getUserId();
//                    SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId2,
//                            Context.MODE_PRIVATE);
//                    int photoMark1 = sp2.getInt("photoMark", 0);
//                    if (photoMark1== 1) {
//                        Thread thread = new Thread(new Runnable() {
//                            @Override
//                            public void run() {
//                                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                mHandler.sendEmptyMessage(0);
//                            }
//                        });
//                        thread.start();
//                    } else if (photoMark1 == 0) {
//                        Thread thread = new Thread(new Runnable() {
//                            @Override
//                            public void run() {
//                                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                                mHandler.sendEmptyMessage(2);
//                            }
//                        });
//                        thread.start();
//                    }
//                }
//
//                break;
        } else if (id == R.id.tv_course10) {//提交
            if (Utils.isFastClicker()) {
                return;
            }
            LoginUserBean userInfo3 = UserManger.getUserInfo();
            String userId2 = userInfo3.getData().getUserId();
            SharedPreferences sp2 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId2,
                    Context.MODE_PRIVATE);
            int tcsn1 = sp2.getInt("tcsn", 0);
            int utchSn1 = sp2.getInt("utchSn", 0);
            int tphotoMark2 = sp2.getInt("tphotoMark", 0);
            int sn2 = sp2.getInt("sn", 0);
            int atcSn2 = sp2.getInt("atcSn", 0);
            String format = sp2.getString("format" + tcsn1 + utchSn1, "");
            String imgurl = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
            int num = sp2.getInt("num" + tcsn1, 0);
//                int tcsn = sp2.getInt("tcsn", 0);
//                int sn = sp2.getInt("sn", 0);
//                String statYm = sp2.getString("statYm", "");
//                String orgId = sp2.getString("orgId", "");
            String[] splitformat = format.split(":");
            String format1 = splitformat[0];
            String format2 = splitformat[1];
            String format3 = splitformat[2];
            int iformat1 = Integer.valueOf(format1);//转int
            int iformat2 = Integer.valueOf(format2);//转int
            int iformat3 = Integer.valueOf(format3);//转int
            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
            if (formattime < num) {//还没到最低学时
                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                builder1.setMessage("学习时间不足，不能提交。");
                builder1.setTitle("提示:");
                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        ;
                        //设置你的操作事项
                    }
                });
                builder1.create().show();

            } else {//已达到最低学时
                if (rowscourseList.size() != 0) {

                    for (int i = 0; i < rowscourseList.size(); i++) {
                        if (rowscourseList.get(i).isSelect() == false) {
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                            builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    //设置你的操作事项
                                }
                            });

                            builder1.create().show();
                            return;
                        } else {

                            if (rowscourseList.get(i).isLOOP() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();

                                return;
                            }
                        }
                    }
                    //  int photoMark1 = sp2.getInt("photoMark", 0);
                    int courseLength = sp2.getInt("courseLength", 0);
                    if (tphotoMark2 == 1) {
                        if (imgurl.equals("")) {
                            String stringTime = sp2.getString("format" + tcsn1 + utchSn1, "");
                            int index1 = stringTime.indexOf(":");
                            int index2 = stringTime.indexOf(":", index1 + 1);
                            int hh = Integer.parseInt(stringTime.substring(0, index1));
                            int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                            int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                            int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                            if (formatTurnSecond > 60) {
                                String firsttime2 = getStringTime(formatTurnSecond);
                                SharedPreferences.Editor edit = sp2.edit();
                                edit.putString("firsttime" + tcsn1, firsttime2);
                                edit.commit();
                                timerTask.cancel();
                                //  tv_pause.setVisibility(View.GONE);
                                initDialog();

                            } else {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("请等待拍照");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                            }


                            return;
                        }
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);
                    } else if (tphotoMark2 == 0) {
                        //有题目调提交接口
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //       String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);
                    } else if (tphotoMark2 == 2) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }

                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第er次抓拍时间
                        String numFifthpartstr11 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setSnapTime(numFifthpartstr11);
                        userTcPhoto1.setUrl(imgurl2);
                        photoList.add(userTcPhoto1);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 3) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr11 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setSnapTime(numFifthpartstr11);
                        userTcPhoto2.setUrl(imgurl3);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 4) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        String imgurl4 = sp2.getString("imgurl3" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第四次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl2);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl3);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl4);
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 5) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        String imgurl4 = sp2.getString("imgurl3" + tcsn1 + utchSn1, "");
                        String imgurl5 = sp2.getString("imgurl4" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        if (imgurl5.equals("")) {
                            timerTask.cancel();
                            initDialog6();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numfourpartstr = sp2.getString("numfourpartstr" + tcsn1, "");//第四次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl2);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl3);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl4);
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl5);
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    }

                } else {
                    int courseLength = sp2.getInt("courseLength", 0);
                    if (tphotoMark2 == 1) {
                        if (imgurl.equals("")) {
                            String stringTime = sp2.getString("format" + tcsn1 + utchSn1, "");
                            int index1 = stringTime.indexOf(":");
                            int index2 = stringTime.indexOf(":", index1 + 1);
                            int hh = Integer.parseInt(stringTime.substring(0, index1));
                            int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                            int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                            int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                            if (formatTurnSecond > 60) {
                                String firsttime2 = getStringTime(formatTurnSecond);
                                SharedPreferences.Editor edit = sp2.edit();
                                edit.putString("firsttime" + tcsn1, firsttime2);
                                edit.commit();
                                timerTask.cancel();
                                //  tv_pause.setVisibility(View.GONE);
                                initDialog();

                            } else {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("请等待拍照");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                            }


                            return;
                        }
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();

                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);
                    } else if (tphotoMark2 == 0) {
                        //有题目调提交接口
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //       String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);
                    } else if (tphotoMark2 == 2) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第er次抓拍时间
                        String numFifthpartstr11 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setSnapTime(numFifthpartstr11);
                        userTcPhoto1.setUrl(imgurl2);
                        photoList.add(userTcPhoto1);

                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 3) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr11 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setSnapTime(numFifthpartstr11);
                        userTcPhoto2.setUrl(imgurl3);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 4) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        String imgurl4 = sp2.getString("imgurl3" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第四次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl2);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl3);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl4);
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    } else if (tphotoMark2 == 5) {
                        String imgurl1 = sp2.getString("imgurl" + tcsn1 + utchSn1, "");
                        String imgurl2 = sp2.getString("imgurl1" + tcsn1 + utchSn1, "");
                        String imgurl3 = sp2.getString("imgurl2" + tcsn1 + utchSn1, "");
                        String imgurl4 = sp2.getString("imgurl3" + tcsn1 + utchSn1, "");
                        String imgurl5 = sp2.getString("imgurl4" + tcsn1 + utchSn1, "");
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        if (imgurl5.equals("")) {
                            timerTask.cancel();
                            initDialog6();
                            return;
                        }
                        String firsttime = sp2.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numfourpartstr = sp2.getString("numfourpartstr" + tcsn1, "");//第四次抓拍时间
                        String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn1, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl2);
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl3);
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl4);
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl5);
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn2, userId2, utchSn1, tcsn1, atcSn2, courseLength, 1, photoList, this, 3);

                    }

                }
            }
        } else if (id == R.id.img_course1) {
            if (!isloob) {
                img_course.setText("展开照片");
                totalle_course.setVisibility(View.GONE);
                img_course2.setImageResource(R.mipmap.down3);
                // le_course1.setVisibility(View.GONE);
                isloob = true;
            } else {
                img_course.setText("收起照片");
                totalle_course.setVisibility(View.VISIBLE);
                img_course2.setImageResource(R.mipmap.top3);
                // le_course1.setVisibility(View.VISIBLE);
                isloob = false;
            }
        }
    }

    //离开保存
    private void initsavedata(int sn, int utchSn, int tcSn, int atcSn, int readLength, List<UserTcPhoto> photoList) {
        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
        mProgressDialog.setMessage("离开保存...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcSn, atcSn, readLength, 0, photoList, this, 4);
    }

    //小窗口离开保存
    private void initsavedata1(int sn, int utchSn, int tcSn, int atcSn, int readLength, List<UserTcPhoto> photoList) {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcSn, atcSn, readLength, 0, photoList, this, 5);
    }

    //自动提交
    private void initsuredata(int sn, int utchSn, int tcSn, int atcSn, int readLength, List<UserTcPhoto> photoList) {
        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
        mProgressDialog.setMessage("自动提交中...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcSn, atcSn, readLength, 1, photoList, this, 3);
    }

    @Override
    public void initData() {
        web = (WebView) findViewById(R.id.wb_course);
        le_parement = (LinearLayout) findViewById(R.id.le_couse);
        img_Courseback = (ImageView) findViewById(R.id.img_Courseback);
        img_course2 = (ImageView) findViewById(R.id.img_course2);
        lv_coursedetail = (RecyclerView) findViewById(R.id.lv_coursedetail);
        jcVideoPlayerStandard = (MyJZVideoPlayerStandard) findViewById(R.id.videoplayer);
        tv_courseName = (TextView) findViewById(R.id.tv_course);
        scroll_view = (ScrollView) findViewById(R.id.scroll_view);
        tv_courseLength = (TextView) findViewById(R.id.tv_course2);
        tv_course12 = (TextView)findViewById(R.id.tv_course12);
        totalle_course = (LinearLayout)findViewById(R.id.totalle_course);
        le_course1 = (LinearLayout)findViewById(R.id.le_course1);
        tv_cumulativeLength = (TextView)findViewById(R.id.tv_course3);
        show_camera_iv = (ImageView)findViewById(R.id.id_show_camera_iv);
        show_camera_iv1 = (ImageView)findViewById(R.id.id_show_camera_iv1);
        show_camera_iv2 = (ImageView)findViewById(R.id.id_show_camera_iv2);
        show_camera_iv3 = (ImageView)findViewById(R.id.id_show_camera_iv3);
        show_camera_iv4 = (ImageView)findViewById(R.id.id_show_camera_iv4);
        tv_sure = (TextView) findViewById(R.id.tv_course10);
        re_course = (RelativeLayout)findViewById(R.id.re_course);
        re_course2 = (RelativeLayout)findViewById(R.id.re_course2);
        img_course = (TextView) findViewById(R.id.img_course1);
        tv_course11 = (TextView)findViewById(R.id.tv_course11);
        playOrPauseFab = (ImageView)findViewById(R.id.img_playorpause);
        tv_playorpause = (TextView)findViewById(R.id.tv_playorpause);
        progress_tv = (TextView)findViewById(R.id.progress_tv);
        total_tv = (TextView)findViewById(R.id.total_tv);
        mSuperFileView = (SuperFileView2) findViewById(R.id.mSuperFileView);
        musicSeekBar=(SeekBar)findViewById(R.id.music_seekbar);

        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        musicHandler = new MusicHandler();
        web.setHorizontalScrollBarEnabled(false);//水平不显示
        web.setVerticalScrollBarEnabled(false); //垂直不显示
        web.setWebViewClient(new WebViewClient() {
            /*
            此处能拦截超链接的url,即拦截href请求的内容。
            */
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return true;
            }
        });

        //注册EventBus
        EventBus.getDefault().register(this);
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorEventListener = new Jzvd.JZAutoFullscreenListener();
        Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);

        timer1 = new Timer();
        Bundle bundle = getIntent().getExtras();
        //通过name关键字取出用户名
        int minPer = bundle.getInt("minPer");
        int atcSn = bundle.getInt("atcSn");
        int tcsn = bundle.getInt("tcsn");
        int utchSn = bundle.getInt("utchSn");//学时系列号
        int tphotoMark = bundle.getInt("tphotoMark");
        int readLength = bundle.getInt("readLength");//保存时间
        int faceRecgMark = bundle.getInt("faceRecgMark");//人脸识别
        int sn = bundle.getInt("sn");
        String photoUrl = bundle.getString("photoUrl");//个人头像
        List<SpecifiedLearningCourseBean.RowsBean> listCourse = (List<SpecifiedLearningCourseBean.RowsBean>) bundle.getSerializable("CourseDetailList");
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt("minPer", minPer);
        edit.putInt("atcSn", atcSn);
        edit.putInt("sn", sn);
        edit.putInt("readLength", readLength);
        edit.putInt("tcsn", tcsn);
        edit.putInt("utchSn", utchSn);
        edit.putInt("tphotoMark", tphotoMark);
        edit.putInt("faceRecgMark", faceRecgMark);
        edit.putString("photoUrl", photoUrl);
        if (readLength > 0) {
            String readLengthstr = getStringTime(readLength * 60);
            edit.putString("format" + tcsn + utchSn, readLengthstr);
            int firsttime2 = (int) (readLength * 60 + 20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime2);
        } else {
            edit.putString("format" + tcsn + utchSn, "");
            int firsttime2 = (int) (80 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            int firsttime = (int) (20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime2" + tcsn, firsttime2);
            edit.putInt("intfirsttime" + tcsn, firsttime);

        }
        Gson gson = new Gson();
        String courseStr = gson.toJson(listCourse); //将List转换成Json
        edit.putString("listCourse", courseStr); //存入json串
        edit.commit();

        if (tphotoMark == 1) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(0);
                }
            });
            thread.start();
        } else if (tphotoMark == 0) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(2);
                }
            });
            thread.start();
        } else if (tphotoMark == 2) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(3);
                }
            });
            thread.start();
        } else if (tphotoMark == 3) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(4);
                }
            });
            thread.start();
        } else if (tphotoMark == 4) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(5);
                }
            });
            thread.start();
        } else if (tphotoMark == 5) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(6);
                }
            });
            thread.start();
        }


//        Thread thread1 = new Thread(new Runnable() {
//            @Override
//            public void run() {
//                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                mHandler.sendEmptyMessage(1);
//            }
//        });
//        thread1.start();
        //摄像头
//        int cameraCount = 1;
//        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
//        cameraCount = Camera.getNumberOfCameras();// 得到摄像头的个数
//
//        for (int i = 0; i < cameraCount; i++) {
//            Camera.getCameraInfo(i, cameraInfo);// 得到每一个摄像头的信息
//            // 现在是后置，变更为前置
//            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
//                /**
//                 * 记得释放camera，方便其他应用调用
//                 */
//                releaseCamera();
//                // 打开当前选中的摄像头
//                mCamera = Camera.open(i);
//                //   mCamera.setDisplayOrientation(90);//旋转度数
//                // 通过surfaceview显示取景画面
//                setStartPreview(mCamera, mHolder);
//
//            }
//        }
//        // 获得句柄
//        mHolder = surfaceSv.getHolder();
//        // 添加回调
//        mHolder.addCallback(this);

        initSeekba();//语音播放ui


    }

    private void initSeekba() {

        musicSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                int musicDuration = mediaPlayer.getDuration();
                if (musicDuration == -1) return;

                if (musicDuration < 0) {
                    progress_tv.setText(MusicUtils.getTime(0));
                    total_tv.setText(MusicUtils.getTime(0));
                } else {
                    progress_tv.setText(MusicUtils.getTime(progress));
                    total_tv.setText(MusicUtils.getTime(musicDuration));
                }
                //  LogUtils.e("musicSeekBar",musicDuration+"");

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                int musicDuration = mediaPlayer.getDuration();
                if (musicDuration == -1) return;
                int progress = seekBar.getProgress();
                mediaPlayer.seekTo(progress);
                mediaPlayer.start();
                progress_tv.setText(MusicUtils.getTime(progress));
                total_tv.setText(MusicUtils.getTime(musicDuration));
            }
        });


        initMusicPlayer();
    }

    public void initMusicPlayer() {
        musicPrepared();
        mediaPlayer.setOnCompletionListener(this);
        mediaPlayer.setOnErrorListener(this);

    }

    public void toggle() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        } else if (tv_playorpause.getText().toString().trim().equals("暂停")) {
            start();
        }
    }

    public void start() {
        //     musicPrepared();
        mediaPlayer.start();
        musicHandler.sendEmptyMessage(0);
        playOrPauseFab.setImageResource(R.mipmap.play);
        tv_playorpause.setText("播放");
        //  isPlaying = true;

    }

    public void pause() {
        mediaPlayer.pause();
        musicHandler.removeMessages(0);
        playOrPauseFab.setImageResource(R.mipmap.stop);
        tv_playorpause.setText("暂停");
        //   isPlaying = false;
        //   fmm.stop();
    }

    private void updateProgress() {
        int musicDuration = mediaPlayer.getDuration();
        LogUtils.e("musicDuration", musicDuration + "");
        if (musicDuration == -1) return;
        int musicProgress = mediaPlayer.getCurrentPosition();
        musicSeekBar.setProgress(musicProgress);
        musicSeekBar.setMax(musicDuration);
        //     fmm.setProgress(musicProgress * 100 / musicDuration);
    }

    private void musicPrepared() {
        try {
            //   AssetFileDescriptor afd = getAssets().openFd("99nights.mp3");
            if (mediaPlayer != null) {
                mediaPlayer.reset();
                mediaPlayer = null;
            }
            mediaPlayer = new MediaPlayer();
            mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            int tcsn = sp.getInt("tcsn", 0);
            int utchSn = sp.getInt("utchSn", 0);
            String accessAudioUrl = sp.getString("accessAudioUrl" + tcsn + utchSn, "");
            if (accessAudioUrl.equals("")) {
                // showToast("语音文件是空");
                return;
            }
            Uri uri = Uri.parse(accessAudioUrl);
            mediaPlayer.setDataSource(EnterpriseAdministratorCourseDetailsActivity.this, uri);
            mediaPlayer.prepareAsync();
            mediaPlayer.setOnPreparedListener(this);

            musicHandler.sendEmptyMessage(0);
            playOrPauseFab.setImageResource(R.mipmap.play);
            tv_playorpause.setText("播放");
//            int duration = mediaPlayer.getDuration();
//            total_tv.setText(MusicUtils.getTime(duration));//刚开始获取时长
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onCompletion(MediaPlayer mp) {
        complete(mp);
    }

    public void complete(MediaPlayer mp) {
        //   isPlaying = false;
        mp.stop();
        musicHandler.removeMessages(0);
        playOrPauseFab.setImageResource(R.mipmap.stop);
        tv_playorpause.setText("暂停");
//        fmm.stop();
//        fmm.setProgress(100);
        musicPrepared();
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.start();
    }

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        LogUtils.e("MMP", "Media player error: what=" + what + ", extra=" + extra);
        return false;
    }

    public class MusicHandler extends Handler {

        @Override
        public void dispatchMessage(Message msg) {
            super.dispatchMessage(msg);
            updateProgress();
            sendEmptyMessageDelayed(0, 1000);
        }
    }

    public void initDataSecond() {
        musicHandler = new MusicHandler();
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorEventListener = new Jzvd.JZAutoFullscreenListener();
        Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);

        timer1 = new Timer();

        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        int tcsn = sp.getInt("tcsn", 0);
        int readLength = sp.getInt("readLength", 0);
        if (readLength > 0) {
            int firsttime2 = (int) (readLength * 60 + 20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime2);
            edit.commit();
        } else {
            int firsttime2 = (int) (80 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime2" + tcsn, firsttime2);
            int firsttime = (int) (20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime);
            edit.commit();
        }
        int tphotoMark = sp.getInt("tphotoMark", 0);
        if (tphotoMark == 1) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(0);
                }
            });
            thread.start();
        } else if (tphotoMark == 0) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(2);
                }
            });
            thread.start();
        } else if (tphotoMark == 2) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(3);
                }
            });
            thread.start();
        } else if (tphotoMark == 3) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(4);
                }
            });
            thread.start();
        } else if (tphotoMark == 4) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(5);
                }
            });
            thread.start();
        } else if (tphotoMark == 5) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(6);
                }
            });
            thread.start();
        }

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                mHandler.sendEmptyMessage(1);
            }
        });
        thread1.start();
//        //摄像头
//        int cameraCount = 1;
//        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
//        cameraCount = Camera.getNumberOfCameras();// 得到摄像头的个数
//
//        for (int i = 0; i < cameraCount; i++) {
//            Camera.getCameraInfo(i, cameraInfo);// 得到每一个摄像头的信息
//            // 现在是后置，变更为前置
//            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
//                /**
//                 * 记得释放camera，方便其他应用调用
//                 */
//                releaseCamera();
//                // 打开当前选中的摄像头
//                mCamera = Camera.open(i);
//                //   mCamera.setDisplayOrientation(90);//旋转度数
//                // 通过surfaceview显示取景画面
//                setStartPreview(mCamera, mHolder);
//
//            }
//        }
//        // 获得句柄
//        mHolder = surfaceSv.getHolder();
//        // 添加回调
//        mHolder.addCallback(this);

        initSeekba();//语音播放ui
    }

    @Override
    public void onSuccess(String result, Call call, Response response, int what) {
        if (what == 3) {
            mProgressDialog.dismiss();
            SignBean signBean = JSON.parseObject(result, SignBean.class);
            final SignBean.DataBean data = signBean.getData();
            if (data.getFinishMark() == 0)//未完成
            {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                String courseStr = sp.getString("listCourse", "");  //取出key为"KEY_PEOPLE_DATA"的值，如果值为空，则将第二个参数作为默认值赋值
                Gson gson = new Gson();
                //将json字符串转换成 people对象
                final List<SpecifiedLearningCourseBean.RowsBean> CourseDetailList = gson.fromJson(courseStr, new TypeToken<List<SpecifiedLearningCourseBean.RowsBean>>() {
                }.getType());
                // int coursePointNo = data.getCoursePointNo();
                if (CourseDetailList.size() > 0) {
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;

//                    if(coursePointNo>0) {
//                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                        View view = View
//                                .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                        TextView tv_message = (TextView) view
//                                .findViewById(R.id.message);//输入内容
//                        tv_message.setText("恭喜您!本课程学习完获得" + coursePointNo + "积分,是否想学习下一课程");
//                        TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                        TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                        btn_sure.setText("学习");
//                        btn_cancel.setText("离开");
//                        final AlertDialog dialog = builder.create();
//                        dialog.show();
//                        dialog.getWindow().setContentView(view);
//                        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                        dialog.setCancelable(false);
//                        btn_sure.setOnClickListener(new View.OnClickListener() {
//                            @Override
//                            public void onClick(View view) {
//                                dialog.dismiss();
//                                scroll_view.fullScroll(ScrollView.FOCUS_UP);//滑到顶部
//                                LoginUserBean userInfo = UserManger.getUserInfo();
//                                String userId = userInfo.getData().getUserId();
//                                SharedPreferences spp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                        Context.MODE_PRIVATE);
//                                int otcSn1 = spp.getInt("otcSn", 0);
//                                int learnsn = spp.getInt("learnsn", 0);
//                                SharedPreferences.Editor editor = spp.edit();
//                                editor.remove("imgurl" + otcSn1+learnsn);
//                                editor.remove("imgurl1" + otcSn1+learnsn);
//                                editor.remove("imgurl2" + otcSn1+learnsn);
//                                editor.remove("accessAudioUrl"+otcSn1+learnsn);
//                                editor.commit();
//                                //设置你的操作事项
//                                int tcSn = CourseDetailList.get(0).getTcSn();
//                                int otcSn = CourseDetailList.get(0).getOtcSn();
//                                int sn = CourseDetailList.get(0).getSn();
//                                int readLength = CourseDetailList.get(0).getReadLength();
//                                SharedPreferences.Editor edit = spp.edit();
//                                edit.putInt("otcSn", otcSn);
//                                edit.putInt("tcsn", tcSn);
//                                edit.putInt("sn", sn);
//                                if(readLength>0)
//                                {
//                                    String readLengthstr = getStringTime(readLength*60);
//                                    edit.putString("format" + otcSn+learnsn,readLengthstr);
//                                }else{
//                                    edit.putString("format" + otcSn+learnsn,"");
//                                }
//                                ArrayList<SpecifiedLearningCourseBean.RowsBean> CourseList = new ArrayList<>();
//                                CourseList.clear();
//                                for (int i = 0; i < CourseDetailList.size(); i++) {
//                                    if (CourseDetailList.get(i).getOtcSn() != otcSn) {
//                                        CourseList.add(CourseDetailList.get(i));
//                                    }
//
//                                }
//                                Gson gson = new Gson();
//                                String courseStr = gson.toJson(CourseList); //将List转换成Json
//                                edit.putString("listCourse", courseStr); //存入json串
//                                edit.commit();
//                                JZVideoPlayer.releaseAllVideos();//释放视频资源
//                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
//                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
//                                mediaPlayer.stop();
//                                musicHandler.removeMessages(0);
//                                playOrPauseFab.setImageResource(R.mipmap.stop);
//                                tv_playorpause.setText("暂停");
//                                musicSeekBar.setProgress(0);
//                                progress_tv.setText(MusicUtils.getTime(0));
//                                total_tv.setText(MusicUtils.getTime(0));
//                                initcourseData();  //根据课程序列号查询课程详情
//                                initcoursesubject(); //根据课程序列号查询测验题
//                                initDataSecond();//初始化
//                                initcoursephoto();//查询拍照照片
//                            }
//                        });
//                        btn_cancel.setOnClickListener(new View.OnClickListener() {
//                            @Override
//                            public void onClick(View view) {
//                                dialog.dismiss();
//                                LoginUserBean userInfo = UserManger.getUserInfo();
//                                String userId = userInfo.getData().getUserId();
//                                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                        Context.MODE_PRIVATE);
//                                SharedPreferences.Editor edit = sp1.edit();
//                                int otcSn1 = sp1.getInt("otcSn", 0);
//                                int learnsn = sp1.getInt("learnsn", 0);
//                                edit.remove("imgurl" + otcSn1+learnsn);
//                                edit.remove("imgurl1" + otcSn1+learnsn);
//                                edit.remove("imgurl2" + otcSn1+learnsn);
//                                edit.remove("format" + otcSn1+learnsn);
//                                edit.remove("firsttime" + otcSn1);
//                                edit.remove("num" + otcSn1);
//                                edit.remove("intfirsttime" + otcSn1);
//                                edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                                edit.remove("tag" + otcSn1);
//                                edit.commit();
//                                finish();
//                            }
//                        });
//                    }else if(coursePointNo==0)//没有获得积分判断
//                    {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("您好,是否想学习下一课程");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_sure.setText("学习");
                    btn_cancel.setText("离开");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            scroll_view.fullScroll(ScrollView.FOCUS_UP);//滑到顶部
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences spp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int tcsn = spp.getInt("tcsn", 0);
                            int utchSn = spp.getInt("utchSn", 0);
                            SharedPreferences.Editor editor = spp.edit();
                            editor.remove("imgurl" + tcsn + utchSn);
                            editor.remove("imgurl1" + tcsn + utchSn);
                            editor.remove("imgurl2" + tcsn + utchSn);
                            editor.remove("imgurl3" + tcsn + utchSn);
                            editor.remove("imgurl4" + tcsn + utchSn);
                            editor.remove("accessAudioUrl" + tcsn + utchSn);
                            editor.commit();
                            //设置你的操作事项
                            int tcSn = CourseDetailList.get(0).getTcSn();
                            int atcSn = CourseDetailList.get(0).getAtcSn();
                            int sn = CourseDetailList.get(0).getSn();
                            int readLength = CourseDetailList.get(0).getReadLength();
                            SharedPreferences.Editor edit = spp.edit();
                            edit.putInt("readLength", readLength);
                            edit.putInt("tcsn", tcSn);
                            edit.putInt("atcSn", atcSn);
                            if (sn == 0) {
                                edit.putInt("sn", 0);
                            } else {
                                edit.putInt("sn", sn);
                            }
                            if (readLength > 0) {

                                String readLengthstr = getStringTime(readLength * 60);
                                edit.putString("format" + tcSn + utchSn, readLengthstr);
                            } else {
                                edit.putString("format" + tcSn + utchSn, "");
                            }
                            ArrayList<SpecifiedLearningCourseBean.RowsBean> CourseList = new ArrayList<>();
                            CourseList.clear();
                            for (int i = 0; i < CourseDetailList.size(); i++) {
                                if (CourseDetailList.get(i).getTcSn() != tcSn) {
                                    CourseList.add(CourseDetailList.get(i));
                                }

                            }
                            Gson gson = new Gson();
                            String courseStr = gson.toJson(CourseList); //将List转换成Json
                            edit.putString("listCourse", courseStr); //存入json串
                            edit.commit();
                            Jzvd.resetAllVideos();
                            ;//释放视频资源
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
                            img_course.setText("展开照片");
                            img_course2.setImageResource(R.mipmap.down3);
                            totalle_course.setVisibility(View.GONE);
                            mediaPlayer.stop();
                            musicHandler.removeMessages(0);
                            musicSeekBar.setProgress(0);
                            playOrPauseFab.setImageResource(R.mipmap.stop);
                            tv_playorpause.setText("暂停");
                            progress_tv.setText(MusicUtils.getTime(0));
                            total_tv.setText(MusicUtils.getTime(0));
                            initcourseData();  //根据课程序列号查询课程详情
                            initcoursesubject(); //根据课程序列号查询测验题
                            initDataSecond();//初始化
                            initcoursephoto();//查询拍照照片

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            int tcsn = sp1.getInt("tcsn", 0);
                            int utchSn = sp1.getInt("utchSn", 0);
                            edit.remove("imgurl" + tcsn + utchSn);
                            edit.remove("imgurl1" + tcsn + utchSn);
                            edit.remove("imgurl2" + tcsn + utchSn);
                            edit.remove("imgurl3" + tcsn + utchSn);
                            edit.remove("imgurl4" + tcsn + utchSn);
                            edit.remove("format" + tcsn + utchSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + utchSn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.remove("tag" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });
                } else if (CourseDetailList.size() == 0) {
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;
                    LoginUserBean userInfo1 = UserManger.getUserInfo();
                    String userId1 = userInfo1.getData().getUserId();
                    SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp1.edit();
                    int tcsn = sp1.getInt("tcsn", 0);
                    int utchSn = sp1.getInt("utchSn", 0);
                    edit.remove("imgurl" + tcsn + utchSn);
                    edit.remove("imgurl1" + tcsn + utchSn);
                    edit.remove("imgurl2" + tcsn + utchSn);
                    edit.remove("imgurl3" + tcsn + utchSn);
                    edit.remove("imgurl4" + tcsn + utchSn);
                    edit.remove("format" + tcsn + utchSn);
                    edit.remove("firsttime" + tcsn);
                    edit.remove("num" + tcsn);
                    edit.remove("accessAudioUrl" + tcsn + utchSn);
                    edit.remove("intfirsttime" + tcsn);
                    edit.remove("tag" + tcsn);
                    edit.commit();
                    finish();
                    showToast("该课程提交成功");
//                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                    View view = View
//                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                    TextView tv_message= (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("恭喜您!本课程学习完成");
//                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                    btn_cancel.setVisibility(View.GONE);
//                    btn_sure.setText("确定");
//                    final    AlertDialog dialog = builder.create();
//                    dialog.show();
//                    dialog.getWindow().setContentView(view);
//                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                    dialog.setCancelable(false);
//                    btn_sure.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//
//                        }
//                    });
                }
            } else if (data.getFinishMark() == 1)//已完成未签名
            {
//                int chPointNo = data.getChPointNo();//完成学时获得积分
//                int coursePointNo = data.getCoursePointNo();//完成课程时获得积分

                timerTask.cancel();
                timer1.cancel();
                timerTask = null;
                timer1 = null;
//                    if(coursePointNo>0&&chPointNo>0) {
//                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                        View view = View
//                                .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                        TextView tv_message = (TextView) view
//                                .findViewById(R.id.message);//输入内容
//                        tv_message.setText("恭喜您!本课程学习完获得" + coursePointNo + "积分,本月学时任务已完成。恭喜额外获得" + chPointNo + "积分");
//                        TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                        TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                        btn_cancel.setVisibility(View.GONE);
//                        btn_sure.setText("确定");
//                        final AlertDialog dialog = builder.create();
//                        dialog.show();
//                        dialog.getWindow().setContentView(view);
//                        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                        dialog.setCancelable(false);
//                        btn_sure.setOnClickListener(new View.OnClickListener() {
//                            @Override
//                            public void onClick(View view) {
//                                dialog.dismiss();
//                                LoginUserBean userInfo = UserManger.getUserInfo();
//                                String userId = userInfo.getData().getUserId();
//                                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                        Context.MODE_PRIVATE);
//                                SharedPreferences.Editor edit = sp1.edit();
//                                int otcSn1 = sp1.getInt("otcSn", 0);
//                                int learnsn = sp1.getInt("learnsn", 0);
//                                Bundle bundle = new Bundle();
//                                bundle.putInt("sn", learnsn);
//                                bundle.putString("signPicUrl", "");
//                                startActivity(SignActivity.class, bundle);
//                                finish();
//                                showToast("该课程提交成功");
//                                edit.remove("imgurl" + otcSn1+learnsn);
//                                edit.remove("imgurl1" + otcSn1+learnsn);
//                                edit.remove("imgurl2" + otcSn1+learnsn);
//                                edit.remove("format" + otcSn1+learnsn);
//                                edit.remove("firsttime" + otcSn1);
//                                edit.remove("num" + otcSn1);
//                                edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                                edit.remove("intfirsttime" + otcSn1);
//                                edit.remove("tag" + otcSn1);
//                                edit.commit();
//                             //   int sn = data.getSn();
//
//                            }
//                        });
//                    }else{
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                Bundle bundle = new Bundle();
                bundle.putInt("sn", utchSn);
                bundle.putString("signPicUrl", "");
                bundle.putInt("signMark", 1);
                startActivity(SignActivity.class, bundle);
                finish();
                SharedPreferences.Editor edit = sp1.edit();
                edit.remove("imgurl" + tcsn + utchSn);
                edit.remove("imgurl1" + tcsn + utchSn);
                edit.remove("imgurl2" + tcsn + utchSn);
                edit.remove("imgurl3" + tcsn + utchSn);
                edit.remove("imgurl4" + tcsn + utchSn);
                edit.remove("format" + tcsn + utchSn);
                edit.remove("firsttime" + tcsn);
                edit.remove("num" + tcsn);
                edit.remove("accessAudioUrl" + tcsn + utchSn);
                edit.remove("intfirsttime" + tcsn);
                edit.remove("tag" + tcsn);
                edit.commit();

            } else if (data.getFinishMark() == 2) {
//                int chPointNo = data.getChPointNo();//完成学时获得积分
//                int coursePointNo = data.getCoursePointNo();//完成课程时获得积分
                timerTask.cancel();
                timer1.cancel();
                timerTask = null;
                timer1 = null;
//                if (chPointNo > 0 && coursePointNo > 0) {
//                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                    View view = View
//                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("恭喜您!本课程学习完获得" + coursePointNo + "积分,本月学时任务已完成。恭喜额外获得" + chPointNo + "积分");
//                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                    btn_cancel.setVisibility(View.GONE);
//                    btn_sure.setText("确定");
//                    final AlertDialog dialog = builder.create();
//                    dialog.show();
//                    dialog.getWindow().setContentView(view);
//                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                    dialog.setCancelable(false);
//                    btn_sure.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//                            LoginUserBean userInfo = UserManger.getUserInfo();
//                            String userId = userInfo.getData().getUserId();
//                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                    Context.MODE_PRIVATE);
//                            SharedPreferences.Editor edit = sp1.edit();
//                            int otcSn1 = sp1.getInt("otcSn", 0);
//                            int learnsn = sp1.getInt("learnsn", 0);
//                            edit.remove("imgurl" + otcSn1+learnsn);
//                            edit.remove("imgurl1" + otcSn1+learnsn);
//                            edit.remove("imgurl2" + otcSn1+learnsn);
//                            edit.remove("format" + otcSn1+learnsn);
//                            edit.remove("firsttime" + otcSn1);
//                            edit.remove("num" + otcSn1);
//                            edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                            edit.remove("intfirsttime" + otcSn1);
//                            edit.remove("tag" + otcSn1);
//                            edit.commit();
//                            finish();
//                            showToast("该课程提交成功");
//                        }
//                    });
//                } else if (coursePointNo > 0 && chPointNo == 0) {
//
//                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                    View view = View
//                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("恭喜您!本课程学习完获得" + coursePointNo + "积分");
//                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                    btn_cancel.setVisibility(View.GONE);
//                    btn_sure.setText("确定");
//                    final AlertDialog dialog = builder.create();
//                    dialog.show();
//                    dialog.getWindow().setContentView(view);
//                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                    dialog.setCancelable(false);
//                    btn_sure.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//                            LoginUserBean userInfo = UserManger.getUserInfo();
//                            String userId = userInfo.getData().getUserId();
//                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                    Context.MODE_PRIVATE);
//                            SharedPreferences.Editor edit = sp1.edit();
//                            int otcSn1 = sp1.getInt("otcSn", 0);
//                            int learnsn = sp1.getInt("learnsn", 0);
//                            edit.remove("imgurl" + otcSn1+learnsn);
//                            edit.remove("imgurl1" + otcSn1+learnsn);
//                            edit.remove("imgurl2" + otcSn1+learnsn);
//                            edit.remove("format" + otcSn1+learnsn);
//                            edit.remove("firsttime" + otcSn1);
//                            edit.remove("num" + otcSn1);
//                            edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                            edit.remove("intfirsttime" + otcSn1);
//                            edit.remove("tag" + otcSn1);
//                            edit.commit();
//                            finish();
//                            showToast("该课程提交成功");
//                        }
//                    });
//
//                } else if (coursePointNo == 0 && chPointNo > 0) {
//                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                    View view = View
//                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("恭喜您!本月学时任务已完成。恭喜额外获得" + chPointNo + "积分");
//                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                    btn_cancel.setVisibility(View.GONE);
//                    btn_sure.setText("确定");
//                    final AlertDialog dialog = builder.create();
//                    dialog.show();
//                    dialog.getWindow().setContentView(view);
//                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                    dialog.setCancelable(false);
//                    btn_sure.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//                            LoginUserBean userInfo = UserManger.getUserInfo();
//                            String userId = userInfo.getData().getUserId();
//                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                    Context.MODE_PRIVATE);
//                            SharedPreferences.Editor edit = sp1.edit();
//                            int otcSn1 = sp1.getInt("otcSn", 0);
//                            int learnsn = sp1.getInt("learnsn", 0);
//                            edit.remove("imgurl" + otcSn1+learnsn);
//                            edit.remove("imgurl1" + otcSn1+learnsn);
//                            edit.remove("imgurl2" + otcSn1+learnsn);
//                            edit.remove("format" + otcSn1+learnsn);
//                            edit.remove("firsttime" + otcSn1);
//                            edit.remove("num" + otcSn1);
//                            edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                            edit.remove("intfirsttime" + otcSn1);
//                            edit.remove("tag" + otcSn1);
//                            edit.commit();
//                            finish();
//                            showToast("该课程提交成功");
//                        }
//                    });
//                } else {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp1.edit();
                int tcsn = sp1.getInt("tcsn", 0);
                int utchSn = sp1.getInt("utchSn", 0);
                edit.remove("imgurl" + tcsn + utchSn);
                edit.remove("imgurl1" + tcsn + utchSn);
                edit.remove("imgurl2" + tcsn + utchSn);
                edit.remove("imgurl3" + tcsn + utchSn);
                edit.remove("imgurl4" + tcsn + utchSn);
                edit.remove("format" + tcsn + utchSn);
                edit.remove("firsttime" + tcsn);
                edit.remove("num" + tcsn);
                edit.remove("accessAudioUrl" + tcsn + utchSn);
                edit.remove("intfirsttime" + tcsn);
                edit.remove("tag" + tcsn);
                edit.commit();
                finish();
                showToast("该课程提交成功");

            }
//            else if(data.getFinishMark()==3)
//            {
//                timerTask.cancel();
//                timer1.cancel();
//                timerTask=null;
//                timer1=null;
//                AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                View view = View
//                        .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
//                TextView tv_message = (TextView) view
//                        .findViewById(R.id.message);//输入内容
//                tv_message.setText("您已完成本月学习，是否进行考试？");
//                TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                btn_sure.setText("去考试");
//                btn_cancel.setText("离开");
//                final AlertDialog dialog = builder.create();
//                dialog.show();
//                dialog.getWindow().setContentView(view);
//                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                dialog.setCancelable(false);
//                btn_sure.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        dialog.dismiss();
//                        LoginUserBean userInfo = UserManger.getUserInfo();
//                        String userId = userInfo.getData().getUserId();
//                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                Context.MODE_PRIVATE);
//                        SharedPreferences.Editor edit = sp1.edit();
//                        int otcSn1 = sp1.getInt("otcSn", 0);
//                        String orgId = sp1.getString("orgId", "");
//                        int learnsn = sp1.getInt("learnsn", 0);
//                        int qpSn = sp1.getInt("qpSn", 0);
//                        Bundle bundle = new Bundle();
//                        bundle.putString("orgId", orgId);
//                        bundle.putInt("qpSn",qpSn);
//                        bundle.putInt("learnsn",learnsn);
//                        startActivity(DailyTrainingExaminationItemActivity.class, bundle);
//                        finish();
//                        showToast("该课程提交成功");
//                        edit.remove("imgurl" + otcSn1+learnsn);
//                        edit.remove("imgurl1" + otcSn1+learnsn);
//                        edit.remove("imgurl2" + otcSn1+learnsn);
//                        edit.remove("imgurl3" + otcSn1+learnsn);
//                        edit.remove("imgurl4" + otcSn1+learnsn);
//                        edit.remove("format" + otcSn1+learnsn);
//                        edit.remove("firsttime" + otcSn1);
//                        edit.remove("num" + otcSn1);
//                        edit.remove("accessAudioUrl"+otcSn1+learnsn);
//                        edit.remove("intfirsttime" + otcSn1);
//                        edit.remove("tag" + otcSn1);
//                        edit.commit();
//
//                    }
//                });
//                btn_cancel.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {//跳回学时界面
//                        dialog.dismiss();
//                        SharedPreferences sp = getSharedPreferences("homefgt", Context.MODE_PRIVATE);
//                        String orgName = sp.getString("orgName", "");
//                        String orgId = sp.getString("orgId", "");
//                        String forbidHour = sp.getString("forbidHour", "");
//                        int minPer = sp.getInt("minPer", 0);
//                        int readInterval = sp.getInt("readInterval", 0);
//                        int Mark = sp.getInt("Mark", 0);
//                        int signMark1 = sp.getInt("signMark", 0);
//                        int photoMark = sp.getInt("photoMark", 0);
//                        int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                        int feeType = sp.getInt("feeType", 0);
//                        String photoUrl = sp.getString("personphotoUrl", "");
//                        int mtSeqMark = sp.getInt("mtSeqMark", 0);
//                        int allowMuT = sp.getInt("allowMuT", 0);
//                        if(faceRecgMark==1) {
//                            Bundle bundle1 = new Bundle();
//                            bundle1.putInt("minPer", minPer);
//                            bundle1.putInt("readInterval", readInterval);
//                            bundle1.putInt("signMark", signMark1);
//                            bundle1.putInt("Mark", Mark);
//                            bundle1.putString("orgId", orgId);
//                            bundle1.putString("forbidHour", forbidHour);
//                            bundle1.putInt("photoMark", photoMark);
//                            bundle1.putInt("faceRecgMark", 1);
//                            bundle1.putString("personphotoUrl", photoUrl);
//                            bundle1.putInt("feeType", feeType);
//                            bundle1.putString("orgName", orgName);
//                            bundle1.putInt("mtSeqMark", mtSeqMark);
//                            bundle1.putInt("allowMuT",allowMuT);
//                            startActivity(SpecifiedLearningHomeActivity.class, bundle1);
//                            finish();
//                        }else if(faceRecgMark==0)
//                        {
//                            Bundle bundle1 = new Bundle();
//                            bundle1.putInt("minPer", minPer);
//                            bundle1.putInt("readInterval", readInterval);
//                            bundle1.putInt("signMark", signMark1);
//                            bundle1.putInt("Mark", Mark);
//                            bundle1.putString("orgId", orgId);
//                            bundle1.putString("forbidHour", forbidHour);
//                            bundle1.putInt("photoMark", photoMark);
//                            bundle1.putInt("faceRecgMark", 0);
//                            bundle1.putString("personphotoUrl", "");
//                            bundle1.putInt("feeType", feeType);
//                            bundle1.putString("orgName", orgName);
//                            bundle1.putInt("mtSeqMark", mtSeqMark);
//                            bundle1.putInt("allowMuT",allowMuT);
//                            startActivity(SpecifiedLearningHomeActivity.class, bundle1);
//                            finish();
//                        }
//
//
//
//
//                    }
//                });
//
//            }
        }
        if (what == 4) {
            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            SharedPreferences.Editor edit = sp1.edit();
            edit.clear();
            edit.commit();
            mProgressDialog.dismiss();
            timerTask.cancel();
            timer1.cancel();
            timerTask = null;
            timer1 = null;
            finish();
        } else if (what == 5) {
//            SignBean signBean = JSON.parseObject(result, SignBean.class);
//            SignBean.DataBean dataBean = signBean.getData();
//            int sn = dataBean.getSn();
//            LoginUserBean userInfo = UserManger.getUserInfo();
//            String userId = userInfo.getData().getUserId();
//            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                    Context.MODE_PRIVATE);
//            SharedPreferences.Editor edit = sp1.edit();
//            edit.putInt("sn",sn);
//            edit.commit();
            //    showToast("自动保存成功");
        }
        super.onSuccess(result, call, response, what);
    }

    @Override
    public void onFailure(Call call, int what) {
        super.onFailure(call, what);
        if (what == 3) {
            mProgressDialog.dismiss();
            Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "提交失败，重新提交", Toast.LENGTH_LONG).show();
        } else if (what == 4) {
            mProgressDialog.dismiss();
            Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "保存失败，重新保存", Toast.LENGTH_LONG).show();
        }

    }

    @Override
    public void onError(String result, Call call, Response response, int what) {
        if (what == 3) {
            mProgressDialog.dismiss();
            CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
            //     int code = checkBean.getCode();
            String msg = checkBean.getMsg();
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
            builder1.setMessage(msg);
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    ;
                    //设置你的操作事项
                }
            });
            builder1.create().show();

        } else if (what == 4) {
            mProgressDialog.dismiss();
            CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
            //     int code = checkBean.getCode();
            String msg = checkBean.getMsg();
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
            builder1.setMessage(msg);
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    ;
                    //设置你的操作事项
                }
            });
            builder1.create().show();
        }

        super.onError(result, call, response, what);
    }


    @Override
    public void requestData() {
        initcoursephoto();//查询拍照照片
        initcourseData();  //根据课程序列号查询课程详情
        initcoursesubject(); //根据课程序列号查询测验题
    }


    //查询拍照照片
    private void initcoursephoto() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int sn = sp.getInt("sn", 0);
        if (sn == 0) {
            le_course1.setVisibility(View.GONE);
            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
            return;
        }
        showLoadingDialog("");
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/userTcPhoto/findTc/" + sn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                dismissLoadingDialog();
                SpecifiedPhotoBean specifiedPhotoBean = JSON.parseObject(result, SpecifiedPhotoBean.class);
                List<SpecifiedPhotoBean.RowsBean> rows = specifiedPhotoBean.getRows();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    }
                    String url = specifiedPhotoBean.getRows().get(0).getUrl();
                    if (url == null) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                    } else {

                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }


                    }
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            //                        }


                        }
                    } else if (rows.size() >= 2) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //     show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //       show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


//                        }
                    }

                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {

                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }


                        //                       }
                    } else if (rows.size() == 2) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //      show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


//                        }
                    } else if (rows.size() >= 3) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //       show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //      show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    }
                    //                   }
                } else if (tphotoMark == 4) {
                    if (rows.size() == 0) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }

                    } else if (rows.size() == 2) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //      show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


                        //                       }
                    } else if (rows.size() == 3) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //       show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //       show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
//                        }
                    } else if (rows.size() >= 4) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //      show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //       show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //       show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + utchSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


                    }
                } else if (tphotoMark == 5) {
                    if (rows.size() == 0) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {

                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }


                        //                      }
                    } else if (rows.size() == 2) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //       show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


//                        }
                    } else if (rows.size() == 3) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //      show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }

                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //     show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }

                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


                        //                       }
                    } else if (rows.size() == 4) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //       show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //     show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //      show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //      show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + utchSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


//                        }
                    } else if (rows.size() >= 5) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
                        String url4 = specifiedPhotoBean.getRows().get(4).getUrl();
//                        if (url == null) {
//                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
//                        } else {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        String format = sp1.getString("format" + tcsn + utchSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                        int numfourpart = sp1.getInt("numfourpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                //      show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + utchSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                //       show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + utchSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //       show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + utchSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //    show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + utchSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                //      show_camera_iv4.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl4" + tcsn + utchSn, url4);
                                edit.commit();
                                if (url4.contains("aliyuncs.com")) {
                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(url4)).placeholder(R.mipmap.no_data).into(show_camera_iv4);
                                } else {

                                    Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url4))).placeholder(R.mipmap.no_data).into(show_camera_iv4);
                                }
                            } else {
                                show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }


                    }
                }

                //              }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                // showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    //根据课程序列号查询测验题
    private void initcoursesubject() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/question/" + tcsn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                CourseDetailSubjectBean courseDetailSubjectBean = JSON.parseObject(result, CourseDetailSubjectBean.class);
                List<CourseDetailSubjectBean.RowsBean> rows = courseDetailSubjectBean.getRows();
                if (rows.size() == 0) {
                    tv_course11.setVisibility(View.GONE);
                    lv_coursedetail.setAdapter(null);
                    return;
                }
                rowscourseList.clear();
                rowscourseList.addAll(rows);
                tv_course11.setVisibility(View.VISIBLE);

                RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(EnterpriseAdministratorCourseDetailsActivity.this);
                lv_coursedetail.setLayoutManager(layoutManager);
                courseDetailSubjectApt = new CourseDetailRvSubjectApt(EnterpriseAdministratorCourseDetailsActivity.this, rowscourseList);
                lv_coursedetail.setAdapter(courseDetailSubjectApt);
                /*courseDetailSubjectApt = new SpecifiedCourseDetailSubjectApt(EnterpriseAdministratorCourseDetailsActivity.this, rowscourseList, R.layout.course_detail_item);
                lv_coursedetail.setAdapter(courseDetailSubjectApt);*/
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });


    }

    //根据课程序列号查询课程详情
    private void initcourseData() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/course/" + tcsn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                CourseDetailBean courseDetailBean = JSON.parseObject(result, CourseDetailBean.class);
                CourseDetailBean.DataBean coursedata = courseDetailBean.getData();
                String courseName = coursedata.getCourseName();//课程名称
                if (courseName != null) {
                    tv_courseName.setText(courseName);
                }
                int courseLength = coursedata.getCourseLength();//课程时长
                tv_courseLength.setText("课程时长:" + courseLength + "分钟");
                //视频地址
                String accessVideoUrl = coursedata.getAccessVideoUrl();
                video(accessVideoUrl);
                //音频地址
                String accessAudioUrl = coursedata.getAccessAudioUrl();
                Audio(accessAudioUrl);
                //课长判断何久拍照
                photo(courseLength);

                //PDF文件解析
                String fileUrl = coursedata.getFileUrl();
                String fileName = coursedata.getFileName();
                if (fileUrl != null) {
                    mSuperFileView.setVisibility(View.VISIBLE);
                    mSuperFileView.setOnGetFilePathListener(new SuperFileView2.OnGetFilePathListener() {
                        @Override
                        public void onGetFilePath(SuperFileView2 mSuperFileView2) {
                            String path = FileParseUtil.getFilePath(mSuperFileView2, fileUrl, fileName);
                            if (path.contains("http")) {//网络地址要先下载
                                showAlertDialog(mSuperFileView2, fileUrl);
                            } else {
                                mSuperFileView2.displayFile(new File(path));
                            }
                        }
                    });
                    mSuperFileView.show();
                }

                String courseContent = coursedata.getCourseContent();
                if (courseContent != null) {
                    new Thread(new runn(courseContent)).start();
                }

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    private String getNewContent(String htmltext) {
        Document doc = Jsoup.parse(htmltext);
        Elements elements = doc.getElementsByTag("img");
        for (Element element : elements) {
            element.attr("width", "100%").attr("height", "auto");
        }

        return doc.toString();
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Bundle data = msg.getData();
            String val = data.getString("value");
            String html = "<html><body>" + val + "</body></html>";
            web.loadDataWithBaseURL(null,
                    getNewContent(html), "text/html", "utf-8",
                    null);
        }
    };

    /**
     * 网络操作相关的子线程
     */
    public class runn implements Runnable {
        String vv;

        public runn(String vv) {
            this.vv = vv;
        }

        @Override
        public void run() {
            Message msg = new Message();
            Bundle data = new Bundle();
            data.putString("value", vv);
            msg.setData(data);
            handler.sendMessage(msg);
        }
    }


    private void photo(int courseLength) {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int minPer = sp.getInt("minPer", 0);
        int readLength = sp.getInt("readLength", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
        int tcsn = sp.getInt("tcsn", 0);
        if (tphotoMark == 1) {
            SharedPreferences.Editor editor = sp.edit();
            int num = (courseLength * 60 * minPer) / 100;
            editor.putInt("num" + tcsn, num);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        } else if (tphotoMark == 0) {
            int num = (courseLength * 60 * minPer) / 100;
            SharedPreferences.Editor editor = sp.edit();
            editor.putInt("num" + tcsn, num);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        } else if (tphotoMark == 2) {
            SharedPreferences.Editor editor = sp.edit();
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;
                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
            } else {
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
            }
//            int numFifthpart = (num * 4) / 5;//五分四提示拍照
//            int Fifthpart = (int)((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
            editor.putInt("num" + tcsn, num);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        } else if (tphotoMark == 3) {
            SharedPreferences.Editor editor = sp.edit();
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;
                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = 30 + readLength * 60 + ((numFifthpart - (30 + readLength * 60)) / 2);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数

            } else {
                course_time = num - readLength * 60;
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + (course_time / 2);//30秒到五分之四时间点的二分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
            }

            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        } else if (tphotoMark == 4) {
            SharedPreferences.Editor editor = sp.edit();
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int thirdpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;

                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 3);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) * 2 / 3);//30秒到五分之四时间点的二分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数

            } else {
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                course_time = num - readLength * 60;
                Fifthpart = (int) ((numFifthpart + 5) + Math.random() * 5);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + (course_time / 3);//30秒到五分之四时间点的三分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + (course_time * 2 / 3);//30秒到五分之四时间点的三分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数


            }

            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numthirdpart" + tcsn, thirdpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        } else if (tphotoMark == 5) {
            SharedPreferences.Editor editor = sp.edit();
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int thirdpart = 0;
            int fourpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;

                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 4);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 2);//30秒到五分之四时间点的二分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数
                int numfourpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) * 3 / 4);//30秒到五分之四时间点的四分之三提示拍照
                fourpart = (int) ((numfourpart - 5) + Math.random() * 10);//第四张上下五秒钟随机数
            } else {
                course_time = num - readLength * 60;
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart + 5) + Math.random() * 5);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + (course_time / 4);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + (course_time / 2);//30秒到五分之四时间点的二分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数
                int numfourpart = readLength * 60 + (course_time * 3 / 4);//30秒到五分之四时间点的四分之三提示拍照
                fourpart = (int) ((numfourpart - 5) + Math.random() * 10);//第四张上下五秒钟随机数
            }


            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numthirdpart" + tcsn, thirdpart);
            editor.putInt("numfourpart" + tcsn, fourpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.putInt("courseLength", courseLength);
            editor.commit();
        }
    }

    private void Audio(String accessAudioUrl) {
        if (accessAudioUrl == null) {
            re_course2.setVisibility(View.GONE);

            return;
        }
        re_course2.setVisibility(View.VISIBLE);
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int utchSn = sp.getInt("utchSn", 0);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("accessAudioUrl" + tcsn + utchSn, accessAudioUrl);
        editor.commit();

    }

    private void video(String accessVideoUrl) {
        if (accessVideoUrl == null) {
            jcVideoPlayerStandard.setVisibility(View.GONE);
            return;
        }
        jcVideoPlayerStandard.setVisibility(View.VISIBLE);
        HashMap headers = new HashMap<String, String>();
        headers.put("Referer",AppInterfaceConfig.BASE_URL);
        JZDataSource jzDataSource=new JZDataSource(accessVideoUrl,"",headers);
        jcVideoPlayerStandard.setUp(jzDataSource,jcVideoPlayerStandard.SCREEN_NORMAL);
        //jcVideoPlayerStandard.setUp(accessVideoUrl, "", jcVideoPlayerStandard.SCREEN_NORMAL, JZMediaIjk.class);
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int readLength = sp.getInt("readLength", 0);
        jcVideoPlayerStandard.seekToInAdvance = readLength * 60 * 1000;
        //  jcVideoPlayerStandard.startVideo();//自动播放
        Picasso.with(getApplicationContext()).load(R.mipmap.video)
                .into(jcVideoPlayerStandard.thumbImageView);

        JzvdStd.progressBar.setEnabled(false);//禁止拖动
    }


    /**
     * 这只是给埋点统计用户数据用的，不能写和播放相关的逻辑，监听事件请参考MyJZVideoPlayerStandard，复写函数取得相应事件
     */
//    class MyUserActionStandard implements JZUserActionStandard {
//
//        @Override
//        public void onEvent(int type, Object url, int screen, Object... objects) {
//            switch (type) {
//                case JZUserAction.ON_CLICK_START_ICON:
//                    Log.i("USER_EVENT", "ON_CLICK_START_ICON" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_CLICK_START_ERROR:
//                    Log.i("USER_EVENT", "ON_CLICK_START_ERROR" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_CLICK_START_AUTO_COMPLETE:
//                    Log.i("USER_EVENT", "ON_CLICK_START_AUTO_COMPLETE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_CLICK_PAUSE:
//                    Log.i("USER_EVENT", "ON_CLICK_PAUSE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_CLICK_RESUME:
//                    Log.i("USER_EVENT", "ON_CLICK_RESUME" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_SEEK_POSITION:
//                    Log.i("USER_EVENT", "ON_SEEK_POSITION" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_AUTO_COMPLETE:
//                    Log.i("USER_EVENT", "ON_AUTO_COMPLETE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_ENTER_FULLSCREEN:
//                    Log.i("USER_EVENT", "ON_ENTER_FULLSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_QUIT_FULLSCREEN:
//                    Log.i("USER_EVENT", "ON_QUIT_FULLSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_ENTER_TINYSCREEN:
//                    Log.i("USER_EVENT", "ON_ENTER_TINYSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_QUIT_TINYSCREEN:
//                    Log.i("USER_EVENT", "ON_QUIT_TINYSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_TOUCH_SCREEN_SEEK_VOLUME:
//                    Log.i("USER_EVENT", "ON_TOUCH_SCREEN_SEEK_VOLUME" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserAction.ON_TOUCH_SCREEN_SEEK_POSITION:
//                    Log.i("USER_EVENT", "ON_TOUCH_SCREEN_SEEK_POSITION" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//
//                case JZUserActionStandard.ON_CLICK_START_THUMB:
//                    Log.i("USER_EVENT", "ON_CLICK_START_THUMB" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                case JZUserActionStandard.ON_CLICK_BLANK:
//                    Log.i("USER_EVENT", "ON_CLICK_BLANK" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen);
//                    break;
//                default:
//                    Log.i("USER_EVENT", "unknow");
//                    break;
//            }
//        }
//    }


    //拍照第一张
    @SuppressLint("HandlerLeak")
    private void initDialog() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 0);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第一张一分之后检查
    @SuppressLint("HandlerLeak")
    private void initDialog2() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
        mPopWindow2 = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);


        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        LinearLayout le_takepicture = (LinearLayout) contentView.findViewById(R.id.le_takepicture1);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mPopWindow2.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 0);
            }
        });
        mPopWindow2.setFocusable(false);
        mPopWindow2.setOutsideTouchable(false);
        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);

    }


    //拍照第二张
    @SuppressLint("HandlerLeak")
    private void initDialog3() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 2);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第三张
    @SuppressLint("HandlerLeak")
    private void initDialog4() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 3);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第四张
    @SuppressLint("HandlerLeak")
    private void initDialog5() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 4);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第四张
    @SuppressLint("HandlerLeak")
    private void initDialog6() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int faceRecgMark = sp.getInt("faceRecgMark", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("faceRecgMark", faceRecgMark);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(TakefacePhotoActivity.class, bundle, 5);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }
    //拍照第二张
    //  @SuppressLint("HandlerLeak")
//    private void initDialog3() {
//        if(tv_playorpause.getText().toString().trim().equals("播放"))
//        {
//            pause();
//        }
//        //设置contentView
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
//        mPopWindow2 = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//
//
//        ImageView takepciture = (ImageView)contentView.findViewById(R.id.img_photo1);//点拍照
//        LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture1);//跟布局
//        takepciture.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                mPopWindow2.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                String photoUrl = sp.getString("photoUrl", "");
//                Bundle bundle = new Bundle();
//                bundle.putInt("faceRecgMark", faceRecgMark);
//                bundle.putString("photoUrl",photoUrl);
//                startActivityForResult(TakefacePhotoActivity.class,bundle, 2);
//            }
//        });
//        mPopWindow2.setFocusable(false);
//        mPopWindow2.setOutsideTouchable(false);
//        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);
//
//    }
    //拍照第三张
//    @SuppressLint("HandlerLeak")
//    private void initDialog4() {
//        if(tv_playorpause.getText().toString().trim().equals("播放"))
//        {
//            pause();
//        }
//        //设置contentView
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
//        mPopWindow2 = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//
//
//        ImageView takepciture = (ImageView)contentView.findViewById(R.id.img_photo1);//点拍照
//        LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture1);//跟布局
//        takepciture.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                mPopWindow2.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                String photoUrl = sp.getString("photoUrl", "");
//                Bundle bundle = new Bundle();
//                bundle.putInt("faceRecgMark", faceRecgMark);
//                bundle.putString("photoUrl",photoUrl);
//                startActivityForResult(TakefacePhotoActivity.class,bundle, 3);
//            }
//        });
//        mPopWindow2.setFocusable(false);
//        mPopWindow2.setOutsideTouchable(false);
//        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);
//
//    }
    //拍照第四张
//    @SuppressLint("HandlerLeak")
//    private void initDialog5() {
//        if(tv_playorpause.getText().toString().trim().equals("播放"))
//        {
//            pause();
//        }
//        //设置contentView
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
//        mPopWindow2 = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//
//
//        ImageView takepciture = (ImageView)contentView.findViewById(R.id.img_photo1);//点拍照
//        LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture1);//跟布局
//        takepciture.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                mPopWindow2.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                String photoUrl = sp.getString("photoUrl", "");
//                Bundle bundle = new Bundle();
//                bundle.putInt("faceRecgMark", faceRecgMark);
//                bundle.putString("photoUrl",photoUrl);
//                startActivityForResult(TakefacePhotoActivity.class,bundle, 4);
//            }
//        });
//        mPopWindow2.setFocusable(false);
//        mPopWindow2.setOutsideTouchable(false);
//        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);
//
//    }
    //拍照第五张
//    @SuppressLint("HandlerLeak")
//    private void initDialog6() {
//        if(tv_playorpause.getText().toString().trim().equals("播放"))
//        {
//            pause();
//        }
//        //设置contentView
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
//        mPopWindow2 = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//
//
//        ImageView takepciture = (ImageView)contentView.findViewById(R.id.img_photo1);//点拍照
//        LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture1);//跟布局
//        takepciture.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                mPopWindow2.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                String photoUrl = sp.getString("photoUrl", "");
//                Bundle bundle = new Bundle();
//                bundle.putInt("faceRecgMark", faceRecgMark);
//                bundle.putString("photoUrl",photoUrl);
//                startActivityForResult(TakefacePhotoActivity.class,bundle, 5);
//            }
//        });
//        mPopWindow2.setFocusable(false);
//        mPopWindow2.setOutsideTouchable(false);
//        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);
//
//    }
//    @SuppressLint("HandlerLeak")
//    private void initStopDialog() {
//        //设置contentView
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.stop_popwindowlayout, null);
//        mStopPopWindow = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//        ImageView takepciture1 = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
//        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
//        takepciture1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                ishave =false;
//                mStopPopWindow.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int photoMark = sp.getInt("photoMark", 0);
//                if (photoMark == 1) {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(0);
//                        }
//                    });
//                    thread.start();
//                } else if (photoMark == 0) {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(2);
//                        }
//                    });
//                    thread.start();
//                }else if(photoMark == 2)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(3);
//                        }
//                    });
//                    thread.start();
//
//                }else if(photoMark == 3)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(4);
//                        }
//                    });
//                    thread.start();
//
//                }else if(photoMark == 4)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(5);
//                        }
//                    });
//                    thread.start();
//
//                }else if(photoMark == 5)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(6);
//                        }
//                    });
//                    thread.start();
//
//                }
//
//            }
//        });

    //        mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                // popupWindow隐藏时恢复屏幕正常透明度
//                setBackgroundAlpha(1.0f);
//            }
//        });
//        setBackgroundAlpha(0.35f);//设置屏幕透明度
//        mPopWindow.setBackgroundDrawable(new BitmapDrawable());
//        mStopPopWindow.setFocusable(false);
//        mStopPopWindow.setOutsideTouchable(false);
//        mStopPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
//
//    }
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (mPopWindow != null && mPopWindow.isShowing()) {
            return false;
        }
        if (mSorryPopWindow != null && mSorryPopWindow.isShowing()) {
            return false;
        }
        if (mStopPopWindow != null && mStopPopWindow.isShowing()) {
            return false;
        }
        if (mPopWindow2 != null && mPopWindow2.isShowing()) {
            return false;
        }

        return super.dispatchTouchEvent(event);
    }

//    private void ShowSorryPopwindow() {
//
//        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.sorry_popwindowlayout, null);
//        mSorryPopWindow = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//        //   LinearLayout le_sorry = (LinearLayout)contentView.findViewById(R.id.le_sorry);//跟布局
//        ImageView sorry_exit = (ImageView)contentView.findViewById(R.id.sorry_img_photo1);//退出
//        sorry_exit.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mSorryPopWindow.dismiss();
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                int photoMark = sp.getInt("photoMark", 0);
//                SharedPreferences.Editor edit = sp.edit();
//                int otcSn = sp.getInt("otcSn", 0);
//                int learnsn = sp.getInt("learnsn", 0);
//                edit.remove("format" + otcSn+learnsn);
//                edit.commit();
//                if(photoMark==1) {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(0);
//                        }
//                    });
//                    thread.start();
//                }else if(photoMark==2)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(3);
//                        }
//                    });
//                    thread.start();
//                }else if(photoMark==3)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(4);
//                        }
//                    });
//                    thread.start();
//                }else if(photoMark == 4)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(5);
//                        }
//                    });
//                    thread.start();
//
//                }else if(photoMark == 5)
//                {
//                    Thread thread = new Thread(new Runnable() {
//                        @Override
//                        public void run() {
//                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                            mHandler.sendEmptyMessage(6);
//                        }
//                    });
//                    thread.start();
//
//                }
//
//            }
//        });
//        mSorryPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                // popupWindow隐藏时恢复屏幕正常透明度
//                setBackgroundAlpha(1.0f);
//            }
//        });
//        setBackgroundAlpha(0.35f);//设置屏幕透明度
    //      mSorryPopWindow.setBackgroundDrawable(new BitmapDrawable());
//        mSorryPopWindow.setFocusable(false);
//        mSorryPopWindow.setOutsideTouchable(false);
//        mSorryPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
//
//    }


    //    private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
//        final double ASPECT_TOLERANCE = 0.1;
//        double targetRatio = (double) w / h;
//        if (sizes == null) return null;
//
//        Camera.Size optimalSize = null;
//        double minDiff = Double.MAX_VALUE;
//
//        int targetHeight = h;
//
//        // Try to find an size match aspect ratio and size
//        for (Camera.Size size : sizes) {
//            double ratio = (double) size.width / size.height;
//            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
//            if (Math.abs(size.height - targetHeight) < minDiff) {
//                optimalSize = size;
//                minDiff = Math.abs(size.height - targetHeight);
//            }
//        }
//
//        // Cannot find the one match the aspect ratio, ignore the requirement
//        if (optimalSize == null) {
//            minDiff = Double.MAX_VALUE;
//            for (Camera.Size size : sizes) {
//                if (Math.abs(size.height - targetHeight) < minDiff) {
//                    optimalSize = size;
//                    minDiff = Math.abs(size.height - targetHeight);
//                }
//            }
//        }
//        return optimalSize;
//    }


    @Override
    public void onBackPressed() {
        if (Jzvd.backPress()) {
            return;
        }
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp1.getInt("tcsn", 0);
        int utchSn = sp1.getInt("utchSn", 0);
        int atcSn = sp1.getInt("atcSn", 0);
        int sn = sp1.getInt("sn", 0);
        int tphotoMark = sp1.getInt("tphotoMark", 0);
        String formats2 = sp1.getString("format" + tcsn + utchSn, "");
        int courseLength2 = sp1.getInt("courseLength", 0);
        String[] splitformat2 = formats2.split(":");
        String formatstr7 = splitformat2[0];
        String formatstr8 = splitformat2[1];
        String formatstr9 = splitformat2[2];
        int iformat7 = Integer.valueOf(formatstr7);//转int
        int iformat8 = Integer.valueOf(formatstr8);//转int
        int iformat9 = Integer.valueOf(formatstr9);//转int
        int formattime2 = iformat7 * 3600 + iformat8 * 60 + iformat9 * 1;
        if (formattime2 < 60) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
            TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
            tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
            TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
            TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
            btn_sure.setText("确认退出");
            btn_cancel.setText("继续学习");
            final AlertDialog dialog = builder.create();
            dialog.show();
            dialog.getWindow().setContentView(view1);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            btn_sure.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.clear();
                    edit.commit();
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;
                    finish();
                    //设置你的操作事项
                }
            });

            btn_cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    dialog.dismiss();
                }
            });


        } else {
            if (formattime2 >= courseLength2 * 60) {
                if (rowscourseList.size() != 0) {
                    for (int i = 0; i < rowscourseList.size(); i++) {
                        if (rowscourseList.get(i).isSelect() == false) {
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                            builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    //设置你的操作事项
                                }
                            });

                            builder1.create().show();
                            return;
                        } else {

                            if (rowscourseList.get(i).isLOOP() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();

                                return;
                            }
                        }
                    }
                }
                //有题目接口
                if (tphotoMark == 1) {//照片提交

                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //                       String durationsub = duration.substring(3,8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("")) {
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                    } else {
                        initsavedata(sn, utchSn, tcsn, atcSn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 0)//无照片提交
                {
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimestr);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);

                    mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                } else if (tphotoMark == 2) {//照片提交


                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第二次抓拍
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("")) {
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                    } else {
                        initsavedata(sn, utchSn, tcsn, atcSn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 3) {//照片提交


                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numFifthpartstr1 = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstrsub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numFifthpartstrsub);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("")) {
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                    } else {
                        initsavedata(sn, utchSn, tcsn, atcSn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 4) {
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String imgurl3 = sp1.getString("imgurl3" + tcsn + utchSn, "");

                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstr1);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("") && !imgurl3.equals("")) {
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                    } else {
                        initsavedata(sn, utchSn, tcsn, atcSn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 5) {
                    String imgurl = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String imgurl3 = sp1.getString("imgurl3" + tcsn + utchSn, "");
                    String imgurl4 = sp1.getString("imgurl4" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String numfourpartstr = sp1.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstr1);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numfourpartstr1);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    userTcPhoto4.setUrl(imgurl4);
                    userTcPhoto4.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("") && !imgurl3.equals("") && !imgurl4.equals("")) {
                        mProgressDialog = new ProgressDialog(EnterpriseAdministratorCourseDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        new Login().getSureBussinessCosrseAndLearn(sn, userId, utchSn, tcsn, atcSn, courseLength2, 1, photoList, this, 3);
                    } else {
                        initsavedata(sn, utchSn, tcsn, atcSn, courseLength2, photoList);
                    }
                }
            } else if (formattime2 < courseLength2 * 60) {//滿一分鐘保存

                int readLength = (formattime2 % 60 == 0) ? formattime2 / 60 : (formattime2 / 60);//累计学习时间
                if (tphotoMark == 1) {

                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 0) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //      String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimestr);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 2) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numFifthpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 3) {
                    //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numFifthpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 4) {
                    //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String imgurl4 = sp1.getString("imgurl3" + tcsn + utchSn, "");
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numFifthpartstr);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);

                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 5) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp1.getString("imgurl" + tcsn + utchSn, "");
                    String firsttimestr = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp1.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp1.getString("imgurl2" + tcsn + utchSn, "");
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String imgurl4 = sp1.getString("imgurl3" + tcsn + utchSn, "");
                    String numfourpartstr = sp1.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                    String imgurl5 = sp1.getString("imgurl4" + tcsn + utchSn, "");
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numfourpartstr);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    if (imgurl5.equals("")) {
                        userTcPhoto4.setSnapTime(numFifthpartstr);
                        userTcPhoto4.setUrl(imgurl5);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        userTcPhoto4.setUrl(imgurl5);
                    }
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                }
//                        }
//                    });
                //              }
            }
        }

        //   super.onBackPressed();
    }


    @Override
    protected void onPause() {
        super.onPause();
        if (sensorManager != null) {
            sensorManager.unregisterListener(sensorEventListener);
        }


        Jzvd.resetAllVideos();

        /**
         * 记得释放camera，方便其他应用调用
         */
        //    releaseCamera();
    }

    //退出后台
    @Override
    protected void onStop() {
        super.onStop();
//        if (timerTask != null) {
//            timerTask.cancel();

//            if (ishave) {
//                ishave = false;
//            } else {
//                ishave = true;
//            }

//        }
        Resave(); //自动保存方法
    }

    //自动保存方法
    public void Resave() {
        //小窗口保存
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId1 = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int utchSn = sp.getInt("utchSn", 0);
        int sn = sp.getInt("sn", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
        int atcSn = sp.getInt("atcSn", 0);
        String formats1 = sp.getString("format" + tcsn + utchSn, "");
        if (!formats1.equals("")) {
            String[] splitformat1 = formats1.split(":");
            String formatstr1 = splitformat1[0];
            String formatstr2 = splitformat1[1];
            String formatstr3 = splitformat1[2];
            int iformat4 = Integer.valueOf(formatstr1);//转int
            int iformat5 = Integer.valueOf(formatstr2);//转int
            int iformat6 = Integer.valueOf(formatstr3);//转int
            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
            if (formattime1 >= 60) {
                int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                if (tphotoMark == 1) {

                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    //String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 0) {
                    //      int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //      String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttime);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 2) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                    String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numFifthpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 3) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                    String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numFifthpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);

                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 4) {
                    //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                    String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                    String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numFifthpartstr);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);

                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                } else if (tphotoMark == 5) {
                    //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                    LogUtils.e("readLength", readLength + "");
                    String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                    String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                    String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                    String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                    String numfourpartstr = sp.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                    String imgurl5 = sp.getString("imgurl4" + tcsn + utchSn, "");
                    String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numfourpartstr);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    if (imgurl5.equals("")) {
                        userTcPhoto4.setSnapTime(numFifthpartstr);
                        userTcPhoto4.setUrl(imgurl5);

                    } else {
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        userTcPhoto4.setUrl(imgurl5);
                    }
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(sn, utchSn, tcsn, atcSn, readLength, photoList);
                }
            }
        }
    }

    //重启前台
    @Override
    protected void onRestart() {
        super.onRestart();
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId1 = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int utchSn = sp.getInt("utchSn", 0);
        int sn = sp.getInt("sn", 0);
        int tag = sp.getInt("tag" + tcsn, 0);
        if (tag == 0) {
            String formats1 = sp.getString("format" + tcsn + utchSn, "");
            String[] splitformat1 = formats1.split(":");
            String formatstr1 = splitformat1[0];
            String formatstr2 = splitformat1[1];
            String formatstr3 = splitformat1[2];
            int iformat4 = Integer.valueOf(formatstr1);//转int
            int iformat5 = Integer.valueOf(formatstr2);//转int
            int iformat6 = Integer.valueOf(formatstr3);//转int
            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
            if (formattime1 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();

                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dialog.dismiss();
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putInt("tag" + tcsn, 0);
                        edit.commit();

                    }
                });

            } else {
                //滿一分鐘保存
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您的学习进度已保存，下次进入将继续本课程的学习。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int atcSn = sp.getInt("atcSn", 0);
                        String formats1 = sp.getString("format" + tcsn + utchSn, "");
                        String[] splitformat1 = formats1.split(":");
                        String formatstr1 = splitformat1[0];
                        String formatstr2 = splitformat1[1];
                        String formatstr3 = splitformat1[2];
                        int iformat4 = Integer.valueOf(formatstr1);//转int
                        int iformat5 = Integer.valueOf(formatstr2);//转int
                        int iformat6 = Integer.valueOf(formatstr3);//转int
                        int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;

                        // int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1: (formattime1 / 60);//累计学习时间
                        int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        if (tphotoMark == 1) {

                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                            //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        } else if (tphotoMark == 0) {
                            //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            //      String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                            //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttime);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        } else if (tphotoMark == 2) {
                            //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                            String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numFifthpartstr);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numFifthpartstr1);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        } else if (tphotoMark == 3) {
                            //    int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                            String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                            String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numFifthpartstr);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numFifthpartstr1);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);

                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        } else if (tphotoMark == 4) {
                            //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                            String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                            String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                            String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                            String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numthirdpartstr);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numthirdpartstr1);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);
                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                            if (imgurl4.equals("")) {
                                userTcPhoto3.setSnapTime(numFifthpartstr);
                                userTcPhoto3.setUrl(imgurl4);

                            } else {
                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto3.setSnapTime(numFifthpartstr1);
                                userTcPhoto3.setUrl(imgurl4);
                            }
                            photoList.add(userTcPhoto3);

                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        } else if (tphotoMark == 5) {
                            //   int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            LogUtils.e("readLength", readLength + "");
                            String imgurl1 = sp.getString("imgurl" + tcsn + utchSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String imgurl2 = sp.getString("imgurl1" + tcsn + utchSn, "");
                            String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String imgurl3 = sp.getString("imgurl2" + tcsn + utchSn, "");
                            String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                            String imgurl4 = sp.getString("imgurl3" + tcsn + utchSn, "");
                            String numfourpartstr = sp.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                            String imgurl5 = sp.getString("imgurl4" + tcsn + utchSn, "");
                            String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00

                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1 = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numthirdpartstr);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numthirdpartstr1 = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numthirdpartstr1);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);
                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                            if (imgurl4.equals("")) {
                                userTcPhoto3.setSnapTime(numfourpartstr);
                                userTcPhoto3.setUrl(imgurl4);

                            } else {
                                String numfourpartstr1 = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto3.setSnapTime(numfourpartstr1);
                                userTcPhoto3.setUrl(imgurl4);
                            }
                            photoList.add(userTcPhoto3);
                            UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                            if (imgurl5.equals("")) {
                                userTcPhoto4.setSnapTime(numFifthpartstr);
                                userTcPhoto4.setUrl(imgurl5);

                            } else {
                                String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto4.setSnapTime(numFifthpartstr1);
                                userTcPhoto4.setUrl(imgurl5);
                            }
                            photoList.add(userTcPhoto4);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(sn, utchSn, tcsn, atcSn, readLength, photoList);
                        }
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId1 = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putInt("tag" + tcsn, 0);
                        edit.commit();
                    }
                });
            }
        } else {
            SharedPreferences.Editor edit = sp.edit();
            edit.putInt("tag" + tcsn, 0);
            edit.commit();
        }


//        LoginUserBean userInfo = UserManger.getUserInfo();
//        String userId = userInfo.getData().getUserId();
//        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                Context.MODE_PRIVATE);
//        int otcSn = sp.getInt("otcSn", 0);
//        int learnsn = sp.getInt("learnsn", 0);
//        int tag = sp.getInt("tag" + otcSn, 0);
//        if (tag == 1) {
//            SharedPreferences.Editor edit = sp.edit();
//            edit.putInt("tag" + otcSn, 0);
//            edit.commit();
//            ishave=false;
//        } else if (tag == 0) {
//            String formatime = sp.getString("format" + otcSn+learnsn, "");
//            String firsttime = sp.getString("firsttime" + otcSn, "");
//            String[] splitformat = formatime.split(":");
//            String formatstr1 = splitformat[0];
//            String formatstr2 = splitformat[1];
//            String formatstr3 = splitformat[2];
//            int iformat1 = Integer.valueOf(formatstr1);//转int
//            int iformat2 = Integer.valueOf(formatstr2);//转int
//            int iformat3 = Integer.valueOf(formatstr3);//转int
//            int formattime1 = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//            if(!firsttime.equals("")) {
//                String[] splitformat1 = firsttime.split(":");
//                String formatstr4 = splitformat1[0];
//                String formatstr5 = splitformat1[1];
//                String formatstr6 = splitformat1[2];
//                int iformat4 = Integer.valueOf(formatstr4);//转int
//                int iformat5 = Integer.valueOf(formatstr5);//转int
//                int iformat6 = Integer.valueOf(formatstr6);//转int
//                int firsttime1 = (iformat4 * 3600 + iformat5 * 60 + iformat6 * 1);
//                if (formattime1 != firsttime1) {
//                    if (ishave) {
//                        initStopDialog();
//                        ishave = true;
//                    } else {
//                        ishave = true;
//                    }
//                } else {
//                    //  tv_pause.setVisibility(View.GONE);
//                }
//
//            }else{
//                if (ishave) {
//                    initStopDialog();
//                    ishave = true;
//                } else {
//                    ishave = true;
//                }
//            }
//
//
//
//        } else if(tag == 2)
//        {
//            SharedPreferences.Editor edit = sp.edit();
//            edit.putInt("tag" + otcSn, 3);
//            edit.commit();
//            ishave=false;
//        }else if(tag == 3)
//        {
//                if(ishave)
//                {
//                   // initStopDialog();
//                    ishave =true;
//                }else{
//                    ishave =true;
//                }
//
//        }

    }

//    @Override
//    public void onStart() {
//        super.onStart();
//        if (this.checkCameraHardware(this) && (mCamera == null)) {
//            // 打开camera
//            mCamera = getCamera();
//            if (mHolder != null) {
//                setStartPreview(mCamera, mHolder);
//            }
//        }
//    }

//    @Override
//    protected void onResume() {
//        super.onResume();
//        //摄像头
//        int cameraCount = 1;
//        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
//        cameraCount = Camera.getNumberOfCameras();// 得到摄像头的个数
//
//        for (int i = 0; i < cameraCount; i++) {
//            Camera.getCameraInfo(i, cameraInfo);// 得到每一个摄像头的信息
//            // 现在是后置，变更为前置
//            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
//                /**
//                 * 记得释放camera，方便其他应用调用
//                 */
//                releaseCamera();
//                // 打开当前选中的摄像头
//                mCamera = Camera.open(i);
//                //   mCamera.setDisplayOrientation(90);//旋转度数
//                // 通过surfaceview显示取景画面
//                setStartPreview(mCamera, mHolder);
//
//            }
//        }
//    }


//    private Camera getCamera() {
//        Camera camera = null;
//        try {
//            camera = Camera.open();
//        } catch (Exception e) {
//            // Camera is not available (in use or does not exist)
//            camera = null;
//            LogUtils.e(TAG, "Camera is not available (in use or does not exist)");
//        }
//        return camera;
//    }


    @Override
    public void onDestroy() {
        super.onDestroy();

        FileParseUtil.releaseFileView();
        if (mPopWindow != null) {

            mPopWindow.dismiss();
        }
        if (mPopWindow2 != null) {

            mPopWindow2.dismiss();
        }
        if (mSorryPopWindow != null) {

            mSorryPopWindow.dismiss();
        }
        if (mStopPopWindow != null) {

            mStopPopWindow.dismiss();
        }
        if (mProgressDialog != null) {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }


        mHandler.removeCallbacksAndMessages(null);
        mOffHandler.removeCallbacksAndMessages(null);
        EventBus.getDefault().unregister(this);//反注册EventBus

        Jzvd.resetAllVideos();
        musicHandler.removeMessages(0);//语音播放器释放
        mediaPlayer.release();//语音播放器释放资源
        SharedPreferences sp = getSharedPreferences("CameraSwitchView",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.clear();
        editor.commit();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(MessageEvent event) {
        String imgurl = event.getMessage();
        String messageurl = event.getMessageurl();
        boolean isphoto = event.isIsphoto();
        int code = event.getCode();
        int faceRecgMark = event.getFaceRecgMark();
        String msg = event.getMsg();
        if (faceRecgMark == 1 || faceRecgMark == 2) {
            if (isphoto) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                Toasty.success(this, "人脸识别成功！", Toast.LENGTH_SHORT, true).show();
                int tcsn = sp.getInt("tcsn", 0);
                int utchSn = sp.getInt("utchSn", 0);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    //    show_camera_iv.setWillNotDraw(false);
                    show_camera_iv.setContentDescription(messageurl);
                    Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                    show_camera_iv.setImageBitmap(bitmapByUrl);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + utchSn, imgurl);
                    edit.commit();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //     show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //    show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //    show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //    show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //      show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //        show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //      show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //       show_camera_iv4.setWillNotDraw(false);
                        show_camera_iv4.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv4.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                }
            } else {
                timerTask.cancel();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int utchSn = sp.getInt("utchSn", 0);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    show_camera_iv.setImageResource(R.mipmap.tongming);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + utchSn, "");
                    edit.commit();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                    }
                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, "");
                        edit.commit();
                    }
                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);

                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);

                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv4.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + utchSn, "");
                        edit.commit();
                    }
                }
                if (code == 1) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("非常抱歉，您还没有上传个人头像，我们无法对您对你进行人脸识别。");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_cancel.setVisibility(View.GONE);
                    btn_sure.setText("上传头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            int tcsn = sp.getInt("tcsn", 0);
                            int utchSn = sp.getInt("utchSn", 0);
                            edit.remove("imgurl" + tcsn + utchSn);
                            edit.remove("imgurl1" + tcsn + utchSn);
                            edit.remove("imgurl2" + tcsn + utchSn);
                            edit.remove("imgurl3" + tcsn + utchSn);
                            edit.remove("imgurl4" + tcsn + utchSn);
                            edit.remove("format" + tcsn + utchSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + utchSn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });
                } else if (code == 2) {

                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("非常抱歉。系统正在进行维护，请您稍后再进行学习。");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_cancel.setVisibility(View.GONE);
                    btn_sure.setText("确定");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            int tcsn = sp.getInt("tcsn", 0);
                            int utchSn = sp.getInt("utchSn", 0);
                            edit.remove("imgurl" + tcsn + utchSn);
                            edit.remove("imgurl1" + tcsn + utchSn);
                            edit.remove("imgurl2" + tcsn + utchSn);
                            edit.remove("imgurl3" + tcsn + utchSn);
                            edit.remove("imgurl4" + tcsn + utchSn);
                            edit.remove("format" + tcsn + utchSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + utchSn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });
                }
//                else if(code==3)
//                {
//                    timerTask.cancel();
//                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                    View view = View
//                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
//                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                    TextView btn_title = (TextView) view.findViewById(R.id.title);
//                    TextView btn_message = (TextView) view.findViewById(R.id.message);
//                    btn_title.setVisibility(View.VISIBLE);
//                    btn_cancel.setText("我的头像");
//                    btn_message.setText("请确保拍照面部完整，五官清晰，如您多次人脸失败，请在“我的头像”中检查您的个人头像是否正常且且清晰。");
//                    final AlertDialog dialog = builder.create();
//                    dialog.show();
//                    dialog.getWindow().setContentView(view);
//                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                    dialog.setCancelable(false);
//                    btn_sure.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//                            LoginUserBean userInfo = UserManger.getUserInfo();
//                            String userId = userInfo.getData().getUserId();
//                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                    Context.MODE_PRIVATE);
//                            int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                            String photoUrl = sp.getString("photoUrl", "");
//                            Bundle bundle = new Bundle();
//                            bundle.putInt("faceRecgMark", faceRecgMark);
//                            bundle.putString("photoUrl",photoUrl);
//                            startActivityForResult(TakefacePhotoActivity.class,bundle, 0);
//
//                        }
//                    });
//                    btn_cancel.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            dialog.dismiss();
//                            showTakePhotoPopupWindow();
//                        }
//                    });
//                }
                else {
                    timerTask.cancel();
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    btn_title.setVisibility(View.VISIBLE);
                    btn_cancel.setText("我的头像");
                    btn_message.setText(msg);
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int faceRecgMark = sp.getInt("faceRecgMark", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("faceRecgMark", faceRecgMark);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(TakefacePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });
                }
            }
        } else if (faceRecgMark == 0) {
            if (isphoto) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int utchSn = sp.getInt("utchSn", 0);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    //       show_camera_iv.setWillNotDraw(false);
                    show_camera_iv.setContentDescription(messageurl);
                    Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                    show_camera_iv.setImageBitmap(bitmapByUrl);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + utchSn, imgurl);
                    edit.commit();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //      show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //       show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //   show_camera_iv.setWillNotDraw(false);

                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //    show_camera_iv1.setWillNotDraw(false);

                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        //   show_camera_iv2.setWillNotDraw(false);

                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //       show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        //       show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //      show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        //        show_camera_iv4.setWillNotDraw(false);
                        show_camera_iv4.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv4.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + utchSn, imgurl);
                        edit.commit();
                    }
                }
            } else {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int utchSn = sp.getInt("utchSn", 0);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    show_camera_iv.setImageResource(R.mipmap.tongming);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + utchSn, "");
                    edit.commit();
                    Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(EnterpriseAdministratorCourseDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv4.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + utchSn, "");
                        edit.commit();
                        Toast.makeText(EnterpriseAdministratorCourseDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                }

            }
        }
    }

    private void showTakePhotoPopupWindow() {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        View view = View
                .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_photo_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("人脸识别失败,请面向镜头重新照相或者重新上传“我的”头像");
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        String photoUrl = sp.getString("photoUrl", "");
        ImageView img_photo = (ImageView) view.findViewById(R.id.img_photo2);
        if (!photoUrl.equals("")) {
            Picasso.with(EnterpriseAdministratorCourseDetailsActivity.this).load(Uri.parse(photoUrl)).placeholder(R.mipmap.my_head).into(img_photo);//加载图片
        }
        TextView btn_PositiveButton = (TextView) view.findViewById(R.id.tv_photo6);//拍照
        TextView btn_NegativeButton = (TextView) view.findViewById(R.id.tv_photo5);//手机获取照片
        final AlertDialog dialog = builder.create();
        dialog.show();
        dialog.getWindow().setContentView(view);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setCancelable(false);
        btn_PositiveButton.setOnClickListener(new View.OnClickListener() {//拍照
            @Override
            public void onClick(View view) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp.edit();
                int tcsn = sp.getInt("tcsn", 0);
                edit.putInt("tag" + tcsn, 1);
                edit.commit();

                startActivityForResult(TakePersonPictureActivity.class, null, 1);
                dialog.dismiss();


            }
        });


    }


    /**
     * 释放mCamera
     */
//    private void releaseCamera() {
//        if (mCamera != null) {
//            mCamera.setPreviewCallback(null);
//            mCamera.stopPreview();// 停掉原来摄像头的预览
//            mCamera.release();
//            mCamera = null;
//        }
//    }

//    @Override
//    public void surfaceCreated(SurfaceHolder holder) {
//
//        setStartPreview(mCamera, mHolder);
//    }

//    @Override
//    public void surfaceChanged(SurfaceHolder holder, int format, int width,
//                               int height) {
//        // If your preview can change or rotate, take care of those events here.
//        // Make sure to stop the preview before resizing or reformatting it.
//
//        if (mHolder.getSurface() == null) {
//            // preview surface does not exist
//            return;
//        }
//        // stop preview before making changes
//        try {
//            mCamera.stopPreview();
//        } catch (Exception e) {
//            // ignore: tried to stop a non-existent preview
//        }
//
//        setStartPreview(mCamera, mHolder);
//
//    }

//    @Override
//    public void surfaceDestroyed(SurfaceHolder holder) {
//        // 当surfaceview关闭时，关闭预览并释放资源
//        /**
//         * 记得释放camera，方便其他应用调用
//         */
//        releaseCamera();
//        holder = null;
//        surfaceSv = null;
//    }


    /**
     * 创建png图片回调数据对象
     */
//    Camera.PictureCallback picture = new Camera.PictureCallback() {
//        @Override
//        public void onPictureTaken(byte[] data, Camera camera) {
//            File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
//            if (pictureFile == null) {
//                Log.d(TAG,
//                        "Error creating media file, check storage permissions: ");
//                return;
//            }
//            try {
//                FileOutputStream fos = new FileOutputStream(pictureFile);
//                fos.write(data);
//                fos.close();
//                FileInputStream fis = new FileInputStream(pictureFile);
//                Bitmap bitmapByUrl = BitmapFactory.decodeStream(fis);
//                bitmapByUrl = compressScale(bitmapByUrl);
//                bitmapByUrl = rotaingImageView(-90, bitmapByUrl);
//
//                SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss ");
//                Date curDate = new Date(System.currentTimeMillis());//获取当前系统时间
//                String str = formatter.format(curDate);
//                Bitmap bitmap = ImageUtil.drawTextToLeftBottom(EnterpriseAdministratorCourseDetailsActivity.this, bitmapByUrl, str, 8, Color.RED, 1, 1);
//
//                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pictureFile));
//                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
//                bos.flush();
//                bos.close();
//
//                returnResult(pictureFile);
//            } catch (FileNotFoundException e) {
//                Log.d(TAG, "File not found: " + e.getMessage());
//            } catch (IOException e) {
//                Log.d(TAG, "Error accessing file: " + e.getMessage());
//            }
//        }
//    };

    /**
     * 图片按比例大小压缩方法
     *
     * @param image （根据Bitmap图片压缩）
     * @return
     */
//    public static Bitmap compressScale(Bitmap image) {
//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
//        image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
//        // 判断如果图片大于1M,进行压缩避免在生成图片（BitmapFactory.decodeStream）时溢出
//        if (baos.toByteArray().length / 1024 > 1024) {
//            baos.reset();// 重置baos即清空baos
//            image.compress(Bitmap.CompressFormat.JPEG, 80, baos);// 这里压缩50%，把压缩后的数据存放到baos中
//        }
//        ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
//        BitmapFactory.Options newOpts = new BitmapFactory.Options();
//        // 开始读入图片，此时把options.inJustDecodeBounds 设回true了
//        newOpts.inJustDecodeBounds = true;
//        Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
//        newOpts.inJustDecodeBounds = false;
//        int w = newOpts.outWidth;
//        int h = newOpts.outHeight;
//        Log.i(TAG, w + "---------------" + h);
//        // 现在主流手机比较多是800*480分辨率，所以高和宽我们设置为
//        // float hh = 800f;// 这里设置高度为800f
//        // float ww = 480f;// 这里设置宽度为480f
//        float hh = 600f;
//        float ww = 450f;
//        // 缩放比。由于是固定比例缩放，只用高或者宽其中一个数据进行计算即可
//        int be = 1;// be=1表示不缩放
//        if (w > h && w > ww) {// 如果宽度大的话根据宽度固定大小缩放
//            be = (int) (newOpts.outWidth / ww);
//        } else if (w < h && h > hh) { // 如果高度高的话根据高度固定大小缩放
//            be = (int) (newOpts.outHeight / hh);
//        }
//        if (be <= 0)
//            be = 1;
//        newOpts.inSampleSize = be; // 设置缩放比例
//        // newOpts.inPreferredConfig = Config.RGB_565;//降低图片从ARGB888到RGB565
//        // 重新读入图片，注意此时已经把options.inJustDecodeBounds 设回false了
//        isBm = new ByteArrayInputStream(baos.toByteArray());
//        bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
//        return bitmap;
//        //return bitmap;
//    }

    //图片旋转
//    public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
//        //旋转图片 动作
//        Matrix matrix = new Matrix();
//        ;
//        matrix.postRotate(angle);
//        System.out.println("angle2=" + angle);
//        // 创建新的图片
//        Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
//                bitmap.getWidth(), bitmap.getHeight(), matrix, true);
//        return resizedBitmap;
//    }


    /**
     * Create a File for saving an image or video
     */
//    private static File getOutputMediaFile(int type) {
//        // To be safe, you should check that the SDCard is mounted
//        // using Environment.getExternalStorageState() before doing this.
//
//        File mediaStorageDir = new File(
//                Environment
//                        .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
//                "MyCameraApp");
//        // This location works best if you want the created images to be shared
//        // between applications and persist after your app has been uninstalled.
//
//        // Create the storage directory if it does not exist
//        if (!mediaStorageDir.exists()) {
//            if (!mediaStorageDir.mkdirs()) {
//                Log.d("MyCameraApp", "failed to create directory");
//                return null;
//            }
//        }
//        // Create a media file name
//        String timeStamp = HelpUtil.getDateFormatString(new Date());
//        File mediaFile;
//        if (type == MEDIA_TYPE_IMAGE) {
//            mediaFile = new File(mediaStorageDir.getPath() + File.separator
//                    + "IMG_" + timeStamp + ".png");
//        } else {
//            return null;
//        }
//        return mediaFile;
//    }

    /**
     * Check if this device has a camera
     */
//    private boolean checkCameraHardware(Context context) {
//        if (context.getPackageManager().hasSystemFeature(
//                PackageManager.FEATURE_CAMERA)) {
//            // this device has a camera
//            return true;
//        } else {
//            // no camera on this device
//            return false;
//        }
//    }

    /*****
     * 接受第二个Activity返回的数据时调用
     *
     * ****/
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        // super.onActivityResult(requestCode, resultCode, data);

        // 根据返回码的不同，设置参数
        switch (requestCode) {
            case 0://拍第一张返回
                if (resultCode == 1) {
                    String url = intent.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        String stringTime = sp.getString("format" + tcsn + utchSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + utchSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 1) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(0);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 2) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(3);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 3) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 1:
                if (resultCode == 1) {
                    final String url = intent.getStringExtra("url");
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("photoUrl", url);
                    edit.commit();
                    AlertDialog.Builder builder = new AlertDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    btn_title.setVisibility(View.INVISIBLE);
                    btn_message.setText("您已重新上传了个人头像，可点击“重新拍照”再次认证");
                    btn_cancel.setText("我的头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int faceRecgMark = sp.getInt("faceRecgMark", 0);
                            Bundle bundle = new Bundle();
                            bundle.putInt("faceRecgMark", faceRecgMark);
                            bundle.putString("photoUrl", url);
                            startActivityForResult(TakefacePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });

                } else if (resultCode == 2) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
                    View view = View
                            .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    TextView btn_title1 = (TextView) view.findViewById(R.id.title1);
                    btn_title.setVisibility(View.INVISIBLE);
                    btn_title1.setText("请点我的头像！");
                    btn_message.setText("您上传了个人头像失败，可点击“我的头像”再次上传");
                    btn_cancel.setText("我的头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int faceRecgMark = sp.getInt("faceRecgMark", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("faceRecgMark", faceRecgMark);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(TakefacePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });

                }
                break;
            case 2://拍第二张返回
                if (resultCode == 1) {
                    if (intent == null) {
                        return;
                    }

                    String url = intent.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        String stringTime = sp.getString("format" + tcsn + utchSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + utchSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 2) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(3);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 3) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 3://拍第三张返回
                if (resultCode == 1) {
                    if (intent == null) {
                        return;
                    }

                    String url = intent.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        String stringTime = sp.getString("format" + tcsn + utchSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + utchSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 3) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 4://拍第四张返回
                if (resultCode == 1) {
                    if (intent == null) {
                        return;
                    }

                    String url = intent.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        String stringTime = sp.getString("format" + tcsn + utchSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + utchSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 5://拍第五张返回
                if (resultCode == 1) {
                    if (intent == null) {
                        return;
                    }
                    String url = intent.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int utchSn = sp.getInt("utchSn", 0);
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        String stringTime = sp.getString("format" + tcsn + utchSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + utchSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
        }

    }


//    private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
//    private final OkHttpClient client = new OkHttpClient();
//    private void uploadImg(File mediaFile, String userId) {
//        // mImgUrls为存放图片的url集合
//        MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
//
//        if (mediaFile != null) {
//            builder.addFormDataPart("headPhoto", mediaFile.getName(), RequestBody.create(MEDIA_TYPE_PNG, mediaFile));
//            builder.addFormDataPart("userId",userId);
//        }
//        MultipartBody requestBody = builder.build();
//        //构建请求
//        Request request = new Request.Builder()
//                .url(AppInterfaceConfig.BASE_URL + "wx/uploadOfHeadPhoto")//地址
//                .post(requestBody)//添加请求体
//                .build();
//        client.newCall(request).enqueue(new Callback() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//                LogUtils.e("上传失败", e.getLocalizedMessage());
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//                String str = response.body().string();
//                LogUtils.e("上传成功", str);
//                UpPhotoBean upPhotoBean = JSON.parseObject(str, UpPhotoBean.class);
//               final  String photoUrl = upPhotoBean.getData();
//                LogUtils.e("上传图片", photoUrl);
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                        Context.MODE_PRIVATE);
//                SharedPreferences.Editor edit = sp.edit();
//                edit.putString("photoUrl",photoUrl);
//                edit.commit();
//                Looper.prepare();
//                AlertDialog.Builder builder = new AlertDialog.Builder(EnterpriseAdministratorCourseDetailsActivity.this);
//                View view = View
//                        .inflate(EnterpriseAdministratorCourseDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
////                    TextView tv_message = (TextView) view
////                            .findViewById(R.id.message);//输入内容
////                    tv_message.setText("人脸识别失败,请面向镜头重新照相或者重新上传“我的”头像");
//                TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
//                TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
//                TextView btn_message = (TextView) view.findViewById(R.id.message);
//                btn_message.setText("您已重新上传了个人头像，可点击“重新拍照”再次认证");
//                btn_cancel.setText("我的头像");
//                final AlertDialog dialog = builder.create();
//                dialog.show();
//                dialog.getWindow().setContentView(view);
//                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//                dialog.setCancelable(false);
//                btn_sure.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        dialog.dismiss();
//                        LoginUserBean userInfo = UserManger.getUserInfo();
//                        String userId = userInfo.getData().getUserId();
//                        SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                                Context.MODE_PRIVATE);
//                        int faceRecgMark = sp.getInt("faceRecgMark", 0);
//                       // String photoUrl = sp.getString("photoUrl", "");
//                        Bundle bundle = new Bundle();
//                        bundle.putInt("faceRecgMark", faceRecgMark);
//                        bundle.putString("photoUrl",photoUrl);
//                        startActivityForResult(TakefacePhotoActivity.class,bundle, 0);
//
//                    }
//                });
//                btn_cancel.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        dialog.dismiss();
////                            timer1.cancel();
////                            timerTask=null;
////                            timer1=null;
////                            LoginUserBean userInfo = UserManger.getUserInfo();
////                            String userId = userInfo.getData().getUserId();
////                            SharedPreferences sp1 = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
////                                    Context.MODE_PRIVATE);
////                            SharedPreferences.Editor edit = sp1.edit();
////                            int otcSn1 = sp1.getInt("otcSn", 0);
////                            int learnsn = sp1.getInt("learnsn", 0);
////                            edit.remove("imgurl" + otcSn1+learnsn);
////                            edit.remove("format" + otcSn1+learnsn);
////                            edit.remove("firsttime" + otcSn1);
////                            edit.remove("num" + otcSn1);
////                            edit.remove("accessAudioUrl"+otcSn1+learnsn);
////                            edit.remove("intfirsttime" + otcSn1);
////                            edit.remove("tag" + otcSn1);
////                            edit.commit();
////                            finish();
//                        showTakePhotoPopupWindow();
//                    }
//                });
//
//                Looper.loop();
//
//
//
//            }
//        });
//
//    }
    /**
     * 外部存储权限申请返回
     */
//    @Override
//    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
//        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//        if (requestCode == WRITE_EXTERNAL_STORAGE_REQUEST_CODE) {
//            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                // Permission Granted
//                gotoCamera();
//            }
//        } else if (requestCode == READ_EXTERNAL_STORAGE_REQUEST_CODE) {
//            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                // Permission Granted
//                gotoPhoto();
//            }
//        }
//    }

    /**
     * 打开截图界面
     */
//    public void gotoClipActivity(Uri uri) {
//        if (uri == null) {
//            return;
//        }
//        Intent intent = new Intent();
//        intent.setClass(EnterpriseAdministratorCourseDetailsActivity.this, ClipImageActivity.class);
//        intent.putExtra("type", type);
//        intent.setData(uri);
//        startActivityForResult(intent, REQUEST_CROP_PHOTO);
//    }

//    /**
//     * 将String类型的时间转换成long,如：12:01:08
//     * @param strTime String类型的时间
//     * @return long类型的时间
//     * */
//    protected long convertStrTimeToLong(String strTime) {
//        // TODO Auto-generated method stub
//        String []timeArry=strTime.split(":");
//        long longTime=0;
//        if (timeArry.length==2) {//如果时间是MM:SS格式
//            longTime=Integer.parseInt(timeArry[0])*1000*60+Integer.parseInt(timeArry[1])*1000;
//        }else if (timeArry.length==3){//如果时间是HH:MM:SS格式
//            longTime=Integer.parseInt(timeArry[0])*1000*60*60+Integer.parseInt(timeArry[1])
//                    *1000*60+Integer.parseInt(timeArry[0])*1000;
//        }
//        return SystemClock.elapsedRealtime()-longTime;
//    }
//    /**
//     * activity返回式返回拍照图片路径
//     *
//     * @param mediaFile
//     */
//    private void returnResult(File mediaFile) {
//
//        Uri uri = Uri.fromFile(mediaFile);
//        String url = uri.toString().substring(uri.toString().indexOf("///") + 2);
//
//        if (url != null && !TextUtils.isEmpty(url)) {
//            show_camera_iv.setContentDescription(url);
//            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(url);
//            show_camera_iv.setImageBitmap(bitmapByUrl);
//            mCamera.startPreview();
//        }
//        uploadImg(mediaFile);
//
//    }

//    private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
//    private final OkHttpClient client = new OkHttpClient();
//
//    private void uploadImg(File mediaFile) {
//
//        // mImgUrls为存放图片的url集合
//        MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
//
//        if (mediaFile != null) {
//            builder.addFormDataPart("headImg", mediaFile.getName(), RequestBody.create(MEDIA_TYPE_PNG, mediaFile));
//        }
//
//
//        MultipartBody requestBody = builder.build();
//        //构建请求
//        Request request = new Request.Builder()
//                .url(AppInterfaceConfig.BASE_URL + "app/course/uploadFromApp")//地址
//                .post(requestBody)//添加请求体
//                .build();
//
//        client.newCall(request).enqueue(new Callback() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//                LogUtils.e("上传失败", e.getLocalizedMessage());
//
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//
//
//                String str = response.body().string();
//                LogUtils.e("上传成功", str);
//                UpPhotoBean upPhotoBean = JSON.parseObject(str, UpPhotoBean.class);
//                String data = upPhotoBean.getData();
//                SharedPreferences sp = getSharedPreferences("imgurl",
//                        Context.MODE_PRIVATE);
//                SharedPreferences.Editor editor = sp.edit();
//                editor.putString("imgurl", data);
//                editor.commit();
//
//                //       Picasso.with(CourseDetailsActivity.this).load(Uri.parse(data)).into(show_camera_iv);//加载图片
//                LogUtils.e("上传图片", data);
//
//            }
//        });
//
//    }


//    private void setStartPreview(Camera camera, SurfaceHolder holder) {
//        try {
//            camera.setPreviewDisplay(holder);
//            //开始预览
//            camera.setDisplayOrientation(90);
//            camera.startPreview();
//        } catch (IOException e) {
//            Log.d(TAG, "Error starting camera preview: " + e.getMessage());
//        }
//    }

    public class SpecifiedCourseDetailSubjectApt extends CommonAdapter<CourseDetailSubjectBean.RowsBean> {
        private final List<CourseDetailSubjectBean.RowsBean> mList;
        private Context context;
        private RadioButton radioButtonA;
        private RadioButton radioButtonB;
        private RadioButton radioButtonC;
        private RadioButton radioButtonD;
        //  private HashMap<String,Boolean> states=new HashMap<String,Boolean>();//记录所有radiobutton被点击的状态

        private LiumRadioGroup radioGroup;


        public SpecifiedCourseDetailSubjectApt(Context context, List<CourseDetailSubjectBean.RowsBean> mList, int itemLayoutId) {
            super(context, mList, itemLayoutId);
            this.context = context;
            this.mList = mList;


        }

        @Override
        public void convert(ViewHolder holder, final CourseDetailSubjectBean.RowsBean item, final int position) {
            TextView tv_course_title = holder.getView(R.id.tv_course2);
            ImageView img_course_img = holder.getView(R.id.img_course_item);
            tv_course_title.setText(position + 1 + ". " + mList.get(position).getQuestionDesc());


            if (mList.get(position).getUrl() == null) {
                img_course_img.setVisibility(View.GONE);

            } else {
                img_course_img.setVisibility(View.VISIBLE);

                if (mList.get(position).getUrl().contains("aliyuncs.com")) {
                    Picasso.with(context).load(Uri.parse(mList.get(position).getUrl())).placeholder(R.mipmap.no_data2).into(img_course_img);
                } else {

                    Picasso.with(context).load(Uri.parse(AppInterfaceConfig.getRequestUrl(mList.get(position).getUrl()))).placeholder(R.mipmap.no_data2).into(img_course_img);
                }
            }
            radioGroup = (LiumRadioGroup) holder.getView(R.id.course_rg);
            radioButtonA = (RadioButton) radioGroup.findViewById(R.id.radioButton_course);
            radioButtonB = (RadioButton) radioGroup.findViewById(R.id.radioButton_course1);
            radioButtonC = (RadioButton) radioGroup.findViewById(R.id.radioButton_course2);
            radioButtonD = (RadioButton) radioGroup.findViewById(R.id.radioButton_course3);


            if (mList.get(position).getOptionA() == null) {
                radioButtonA.setVisibility(View.GONE);

            } else {
                radioButtonA.setVisibility(View.VISIBLE);
                radioButtonA.setText("A." + mList.get(position).getOptionA());
            }
            if (mList.get(position).getOptionB() == null) {
                radioButtonB.setVisibility(View.GONE);

            } else {
                radioButtonB.setVisibility(View.VISIBLE);
                radioButtonB.setText("B." + mList.get(position).getOptionB());
            }

            if (mList.get(position).getOptionC() == null) {
                radioButtonC.setVisibility(View.GONE);

            } else {
                radioButtonC.setVisibility(View.VISIBLE);
                radioButtonC.setText("C." + mList.get(position).getOptionC());
            }


            if (mList.get(position).getOptionD() == null) {
                radioButtonD.setVisibility(View.GONE);

            } else {
                radioButtonD.setVisibility(View.VISIBLE);
                radioButtonD.setText("D." + mList.get(position).getOptionD());
            }

            radioGroup.setOnCheckedChangeListener(new LiumRadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(LiumRadioGroup group, int checkedId) {
                    item.setSelect(true);
//                    LoginUserBean userInfo = UserManger.getUserInfo();
//                    String userId = userInfo.getData().getUserId();
//                    SharedPreferences sp = getSharedPreferences("EnterpriseAdministratorCourseDetailsActivity" + userId,
//                            Context.MODE_PRIVATE);
//                    int otcSn = sp.getInt("otcSn", 0);
//                    int learnsn = sp.getInt("learnsn", 0);
//                    String format = sp.getString("format"+ otcSn+learnsn, "");
//                    int num = sp.getInt("num"+ otcSn, 0);
//                    String[] splitformat = format.split(":");
//                    String format1 = splitformat[0];
//                    String format2 = splitformat[1];
//                    String format3 = splitformat[2];
//                    int iformat1 = Integer.valueOf(format1);//转int
//                    int iformat2 = Integer.valueOf(format2);//转int
//                    int iformat3 = Integer.valueOf(format3);//转int
//                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    if (checkedId == R.id.radioButton_course) {//                            if(formattime < num)
//                            {
//                                radioButtonA.setChecked(false);
//                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                                builder1.setMessage("学习时间不足，暂不能答题。");
//                                builder1.setTitle("提示:");
//                                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
//                                    public void onClick(DialogInterface dialog, int which) {
//                                        dialog.dismiss();;
//                                        //设置你的操作事项
//                                    }
//                                });
//                                builder1.create().show();
//
//
//                                return;
//                            }

                        //                          radioButtonA.setChecked(true);
                        String s_A = radioButtonA.getText().toString();
                        String right_A = mList.get(position).getRightOption();
                        if ("A".equals(right_A)) {
                            item.setLOOP(true);
//                           TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                           builder1.setMessage("A是正确答案");
//                           builder1.setTitle("提示:");
//                           builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                               public void onClick(DialogInterface dialog, int which) {
//                                   dialog.dismiss();;
//                                   //设置你的操作事项
//                               }
//                           });
//                           builder1.create().show();

                        } else {
                            item.setLOOP(false);
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
                            builder1.setMessage("A不是正确答案");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();
//                                if(right_A.equals("B"))
//                                {
//                                    radioButtonB.startAnimation(animation);
//
//                                }else if(right_A.equals("C"))
//                                {
//                                    radioButtonC.startAnimation(animation);
//                                }else if(right_A.equals("D"))
//                                {
//                                    radioButtonD.startAnimation(animation);
//                                }

                        }
                    } else if (checkedId == R.id.radioButton_course1) {//                            if(formattime < num)
//                            {
//
//                                radioButtonB.setChecked(false);
//                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                                builder1.setMessage("学习时间不足，暂不能答题。");
//                                builder1.setTitle("提示:");
//                                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
//                                    public void onClick(DialogInterface dialog, int which) {
//                                        dialog.dismiss();;
//                                        //设置你的操作事项
//                                    }
//                                });
//                                builder1.create().show();
//
//
//                                return;
//                            }

                        //                          radioButtonB.setChecked(true);
                        String s_B = radioButtonB.getText().toString();
                        String right_B = mList.get(position).getRightOption();
                        if ("B".equals(right_B)) {
                            item.setLOOP(true);
//                           TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                           builder1.setMessage("B是正确答案");
//                           builder1.setTitle("提示:");
//                           builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                               public void onClick(DialogInterface dialog, int which) {
//                                   dialog.dismiss();;
//                                   //设置你的操作事项
//                               }
//                           });
//                           builder1.create().show();

                        } else {
                            item.setLOOP(false);
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
                            builder1.setMessage("B不是正确答案");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();
//                                 if(right_B.equals("A"))
//                                {
//                                    radioButtonA.startAnimation(animation);
//                                }else if(right_B.equals("C"))
//                                {
//                                    radioButtonC.startAnimation(animation);
//                                }else if(right_B.equals("D"))
//                                {
//                                    radioButtonD.startAnimation(animation);
//                                }

                        }
                    } else if (checkedId == R.id.radioButton_course2) {//                            if(formattime < num)
//                            {
//
//                                radioButtonC.setChecked(false);
//                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                                builder1.setMessage("学习时间不足，暂不能答题。");
//                                builder1.setTitle("提示:");
//                                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
//                                    public void onClick(DialogInterface dialog, int which) {
//                                        dialog.dismiss();;
//                                        //设置你的操作事项
//                                    }
//                                });
//                                builder1.create().show();
//
//
//                                return;
//                            }

                        //                           radioButtonC.setChecked(true);
                        String s_C = radioButtonC.getText().toString();
                        String right_C = mList.get(position).getRightOption();
                        if ("C".equals(right_C)) {
                            item.setLOOP(true);
//                           TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                           builder1.setMessage("C是正确答案");
//                           builder1.setTitle("提示:");
//                           builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                               public void onClick(DialogInterface dialog, int which) {
//                                   dialog.dismiss();;
//                                   //设置你的操作事项
//                               }
//                           });
//                           builder1.create().show();

                        } else {
                            item.setLOOP(false);
//                                if(right_C.equals("A"))
//                                {
//                                    radioButtonA.startAnimation(animation);
//                                }else if(right_C.equals("B"))
//                                {
//                                    radioButtonB.startAnimation(animation);
//                                }else if(right_C.equals("D"))
//                                {
//                                    radioButtonD.startAnimation(animation);
//                                }
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
                            builder1.setMessage("C不是正确答案");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();

                        }
                    } else if (checkedId == R.id.radioButton_course3) {//                            if(formattime < num)
//                            {
//                                radioButtonD.setChecked(false);
//                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                                builder1.setMessage("学习时间不足，暂不能答题。");
//                                builder1.setTitle("提示:");
//                                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
//                                    public void onClick(DialogInterface dialog, int which) {
//                                        dialog.dismiss();;
//                                        //设置你的操作事项
//                                    }
//                                });
//                                builder1.create().show();
//
//
//                                return;
//                            }

                        //                           radioButtonD.setChecked(true);
                        String s_D = radioButtonD.getText().toString();
                        String right_D = mList.get(position).getRightOption();
                        if ("D".equals(right_D)) {
                            item.setLOOP(true);
//                           TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                           builder1.setMessage("D是正确答案");
//                           builder1.setTitle("提示:");
//                           builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                               public void onClick(DialogInterface dialog, int which) {
//                                   dialog.dismiss();;
//                                   //设置你的操作事项
//                               }
//                           });
//                           builder1.create().show();

                        } else {
                            item.setLOOP(false);
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
                            builder1.setMessage("D不是正确答案");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();
//                                if(right_D.equals("A"))
//                                {
//                                    radioButtonA.startAnimation(animation);
//                                }else if(right_D.equals("B"))
//                                {
//                                    radioButtonB.startAnimation(animation);
//                                }else if(right_D.equals("C"))
//                                {
//                                    radioButtonD.startAnimation(animation);
//                                }


                        }
                    }
                }
            });
        }
    }

    private void showAlertDialog(SuperFileView2 superFileView2, String url) {
        //1、使用Dialog、设置style
        //2、设置布局

        View contentView = LayoutInflater.from(EnterpriseAdministratorCourseDetailsActivity.this).inflate(R.layout.dialog_circle, null);
        mDownloadPopWindow = new PopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        mDownloadPopWindow.setContentView(contentView);
        mDownloadPopWindow.setFocusable(false);
        mDownloadPopWindow.setOutsideTouchable(false);
        mDownloadPopWindow.showAtLocation(contentView, Gravity.CENTER, 0, 0);


        CircularProgressView circularProgressView = contentView.findViewById(R.id.circleProgress);
        TextView textView = contentView.findViewById(R.id.progressTxt);
        TextView textView1 = contentView.findViewById(R.id.hintTxt);

        jumpingBeans2 = JumpingBeans.with(textView1)
                .makeTextJump(0, textView1.getText().length())
                .setIsWave(true)
                .setLoopDuration(3000)
                .build();

        downLoadFromNet(url, superFileView2, circularProgressView, textView);
    }

    private void downLoadFromNet(final String url, final SuperFileView2 superFileView, CircularProgressView circularProgressView, TextView tv1) {
        //showLoadingDialog("文件下载中...");
        //1.网络下载、存储路径、
        File cacheFile = FileParseUtil.getCacheFile(url);
        if (cacheFile.exists()) {
            if (cacheFile.length() <= 0) {
                cacheFile.delete();
                return;
            }
        }

        OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(20, TimeUnit.SECONDS).readTimeout(20, TimeUnit.SECONDS).build();
        Request request = new Request.Builder().get().url(url).build();
        okHttpClient.newCall(request).enqueue(new okhttp3.Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                //请求成功,从服务器的响应对象中获取apk,流(服务器 输入流(提供数据)  本地 输出流(写入文件))
                ResponseBody body = response.body();
                //告知progressDialog总进度,不变
                //progressDialog.setMax((int) body.contentLength());
                final int allLength = (int) body.contentLength();
                //inputStream就是服务器把需要下载的apk以流的形式提供给客户端
                InputStream inputStream = body.byteStream();

                String fileName = url.substring(url.lastIndexOf("/"));
                String directory = Environment.getExternalStoragePublicDirectory
                        (Environment.DIRECTORY_DOWNLOADS).getPath();
                //File file = new File(directory+fileName);

                File file = FileParseUtil.getCacheFile(url);
                FileOutputStream fos = new FileOutputStream(file);
                byte[] bytes = new byte[1024];
                int len = 0;
                int temp = 0;//用于记录目前下载的到的位置
                while ((len = inputStream.read(bytes)) != -1) {
                    //将读过的数据写入文件中
                    fos.write(bytes, 0, len);
                    //告知progressDialog在下载过程中的当前进度
                    temp += len;
                    //将当前的下载位置,设置给progressDialog
                    //progressDialog.setProgress(temp);
                    //没下载一段数据,睡眠一段时间

                    int progress = (int) (temp * 100.0 / allLength);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            circularProgressView.setProgress(progress);
                            tv1.setText(progress + "%");
                        }
                    });

                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        //2.ACache记录文件的有效期
                        mDownloadPopWindow.dismiss();
                        superFileView.displayFile(file);
                    }
                });
            }
        });
    }


}